From 0b593462b437d6bbeeddb7ebbe4bbff3f818784a Mon Sep 17 00:00:00 2001 From: xxm Date: Sun, 16 Aug 2026 10:09:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20hk=5Fbacktest=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E5=85=A5=E5=9C=BA=E5=AD=97=E6=AE=B5(mkt=5Fret20=5Fmax/mkt=5Frs?= =?UTF-8?q?i=5Fmax/ret1=5Fmin/ret5=5Fmin/ret20=5Fmax/dist=5Flo20=5Fmin/bia?= =?UTF-8?q?s20=5Fmax)=E2=80=94=E2=80=94hk=5Fmr2=E7=A0=94=E5=8F=91=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/hk_backtest.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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"])