Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the empty price_s case and self.instruments in SBBStrategyEMA. #1677

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions qlib/backtest/report.py
Expand Up @@ -427,6 +427,10 @@ def _get_base_vol_pri(
# NOTE ~(price_s < 1e-08) is different from price_s >= 1e-8
# ~(np.NaN < 1e-8) -> ~(False) -> True

# if price_s is empty
if price_s.empty:
return None, None

assert isinstance(price_s, idd.SingleData)
if agg == "vwap":
volume_s = trade_exchange.get_volume(inst, trade_start_time, trade_end_time, method=None)
Expand Down
2 changes: 2 additions & 0 deletions qlib/contrib/strategy/rule_strategy.py
Expand Up @@ -328,6 +328,8 @@ def __init__(
self.instruments = "all"
if isinstance(instruments, str):
self.instruments = D.instruments(instruments)
if isinstance(instruments, List):
self.instruments = instruments
self.freq = freq
super(SBBStrategyEMA, self).__init__(
outer_trade_decision, level_infra, common_infra, trade_exchange=trade_exchange, **kwargs
Expand Down