Skip to content

Commit

Permalink
盘前集合竞价成交量数据修改为可采用 rqdatac.get_open_auction_info 的数据
Browse files Browse the repository at this point in the history
  • Loading branch information
Lin-Dongzhao committed Mar 13, 2024
1 parent 7ae25e5 commit de75f46
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions rqalpha/data/data_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ def get_open_auction_bar(self, order_book_id, dt):
"datetime", "open", "limit_up", "limit_down", "volume", "total_turnover"
]}
return PartialBarObject(instrument, bar)

def get_open_auction_volume(self, order_book_id, dt):
instrument = self.instruments(order_book_id)
try:
volume = self._data_source.get_open_auction_volume(instrument, dt)
except NotImplementedError:
volume = self.get_open_auction_bar(order_book_id, dt).volume
return volume

def history(self, order_book_id, bar_count, frequency, field, dt):
data = self.history_bars(order_book_id, bar_count, frequency,
Expand Down
14 changes: 14 additions & 0 deletions rqalpha/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,20 @@ def get_open_auction_bar(self, instrument, dt):
datetime, open, limit_up, limit_down, volume, total_turnover
"""
raise NotImplementedError

def get_open_auction_volume(self, instrument, dt):
"""
获取指定资产当日的集合竞价成交量
:param instrument: 合约对象
:type instrument: class:`~Instrument`
:param dt: 集合竞价时间
:type dt: datetime.datetime
:return: `float`
"""
raise NotImplementedError

def get_settle_price(self, instrument, date):
"""
Expand Down
2 changes: 1 addition & 1 deletion rqalpha/mod/rqalpha_mod_sys_simulation/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _open_auction_deal_price_decider(self, order_book_id, _):

def _get_bar_volume(self, order, open_auction=False):
if open_auction:
volume = self._env.data_proxy.get_open_auction_bar(order.order_book_id, self._env.trading_dt).volume
volume = self._env.data_proxy.get_open_auction_volume(order.order_book_id, self._env.trading_dt)
else:
if isinstance(order.style, ALGO_ORDER_STYLES):
_, volume = self._env.data_proxy.get_algo_bar(order.order_book_id, order.style, self._env.calendar_dt)
Expand Down

0 comments on commit de75f46

Please sign in to comment.