diff --git a/deploy/profile-scripts/hk_backtest.py b/deploy/profile-scripts/hk_backtest.py index d86173f1..7c785c57 100644 --- a/deploy/profile-scripts/hk_backtest.py +++ b/deploy/profile-scripts/hk_backtest.py @@ -65,6 +65,20 @@ def gen_trades_defensive(panel, strat, strike=3, cooldown_days=15): cond &= panel["rsi"] - panel.groupby("code")["rsi"].shift(5) >= e["rsi_delta_min"] if "vol_ratio_min" in e: cond &= panel["vol_ratio"] > e["vol_ratio_min"] + if "mkt_ret20_max" in e: + cond &= panel["mkt_ret20"] < e["mkt_ret20_max"] + if "mkt_rsi_max" in e: + cond &= panel["mkt_rsi"] < e["mkt_rsi_max"] + if "ret1_min" in e: + cond &= panel["ret1"] > e["ret1_min"] + if "ret5_min" in e: + cond &= panel["ret5"] > e["ret5_min"] + if "ret20_max" in e: + cond &= panel["ret20"] < e["ret20_max"] + if "dist_lo20_min" in e: + cond &= panel["dist_lo20"] > e["dist_lo20_min"] + if "bias20_max" in e: + cond &= panel["bias20"] < e["bias20_max"] sig = panel[cond].copy() sig = sig.dropna(subset=["close"])