feat: hk_backtest扩展入场字段(mkt_ret20_max/mkt_rsi_max/ret1_min/ret5_min/ret20_max/dist_lo20_min/bias20_max)——hk_mr2研发支持

This commit is contained in:
xxm
2026-08-16 10:09:50 +08:00
parent 4404e6c637
commit 0b593462b4
+14
View File
@@ -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"])