Skip to content

Commit

Permalink
调整默认撮合方式
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhou-JiaJun committed Aug 2, 2022
1 parent 9268af8 commit 57d11c7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
9 changes: 5 additions & 4 deletions docs/source/api/base_api.rst
Expand Up @@ -585,11 +585,12 @@ time_rule - 定时间运行
scheduler.run_daily(function, time_rule='before_trading')
* 每天十点运行
* 每天十点运行:

.. code-block:: python3
:linenos:
scheduler.run_daily(function, time_rule=physical_time(hour=10, minute=0))
.. code-block:: python3
:linenos:
scheduler.run_daily(function, time_rule=physical_time(hour=10, minute=0))
.. _api-base-types:

Expand Down
3 changes: 2 additions & 1 deletion rqalpha/mod/rqalpha_mod_sys_simulation/__init__.py
Expand Up @@ -23,7 +23,8 @@
# 日回测的可选值为 "current_bar"|"vwap"(以当前 bar 收盘价|成交量加权平均价撮合)
# 分钟回测的可选值有 "current_bar"|"next_bar"|"vwap"(以当前 bar 收盘价|下一个 bar 的开盘价|成交量加权平均价撮合)
# tick 回测的可选值有 "last"|"best_own"|"best_counterparty"(以最新价|己方最优价|对手方最优价撮合)和 "counterparty_offer"(逐档撮合)
"matching_type": "current_bar",
# matching_type 为 None 则表示根据回测频率自动选择。日/分钟回测下为 current_bar , tick 回测下为 last
"matching_type": None,
# 开启对于处于涨跌停状态的证券的撮合限制
"price_limit": True,
# 开启对于对手盘无流动性的证券的撮合限制(仅在 tick 回测下生效)
Expand Down
13 changes: 11 additions & 2 deletions rqalpha/mod/rqalpha_mod_sys_simulation/mod.py
Expand Up @@ -36,7 +36,7 @@ def start_up(self, env, mod_config):
if env.config.base.run_type == RUN_TYPE.LIVE_TRADING:
return

mod_config.matching_type = self.parse_matching_type(mod_config.matching_type)
mod_config.matching_type = self.parse_matching_type(mod_config.matching_type, env.config.base.frequency)

if env.config.base.margin_multiplier <= 0:
raise patch_user_exc(ValueError(_(u"invalid margin multiplier value: value range is (0, +∞]")))
Expand Down Expand Up @@ -77,7 +77,16 @@ def tear_down(self, code, exception=None):
pass

@staticmethod
def parse_matching_type(me_str):
def parse_matching_type(me_str, frequency):
if me_str is None:
# None 表示根据 frequency 自动选择
if frequency in ["1d", "1m"]:
me_str = "current_bar"
elif frequency == "tick":
me_str = "last"
else:
raise ValueError("frequency only support ['1d', '1m', 'tick']")

assert isinstance(me_str, six.string_types)
me_str = me_str.lower()
if me_str == "current_bar":
Expand Down

0 comments on commit 57d11c7

Please sign in to comment.