Skip to content

Commit

Permalink
Fix the empty price_s case and self.instruments in SBBStrategyEMA.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiahungTai committed Oct 21, 2023
1 parent fb80e31 commit 5113bda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions qlib/backtest/report.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 5113bda

Please sign in to comment.