diff --git a/qlib/backtest/report.py b/qlib/backtest/report.py index 89f595df75..d0d327d03c 100644 --- a/qlib/backtest/report.py +++ b/qlib/backtest/report.py @@ -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) diff --git a/qlib/contrib/strategy/rule_strategy.py b/qlib/contrib/strategy/rule_strategy.py index f2b9197393..4c1fc2f16c 100644 --- a/qlib/contrib/strategy/rule_strategy.py +++ b/qlib/contrib/strategy/rule_strategy.py @@ -326,8 +326,10 @@ def __init__( if instruments is None: warnings.warn("`instruments` is not set, will load all stocks") self.instruments = "all" - if isinstance(instruments, str): + elif isinstance(instruments, str): self.instruments = D.instruments(instruments) + elif 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