From 6840dbd1b36eeb03c08db2e86118d72ca2ff738d Mon Sep 17 00:00:00 2001 From: hmo Date: Sat, 15 Aug 2026 04:06:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B8=AF=E8=82=A1=E7=BB=84=E5=90=88?= =?UTF-8?q?=E8=BE=BE=E6=A0=87=E2=80=94=E2=80=94=E6=B8=A9=E5=8C=BA=E4=BA=92?= =?UTF-8?q?=E8=A1=A5(=E4=BD=8EPE+=E8=A1=8C=E4=B8=9A=E5=8A=A8=E9=87=8Ftrend?= =?UTF-8?q?=5Fup/=E6=B7=B1=E5=BA=A6=E8=B6=85=E5=8D=96trend=5Fdown/?= =?UTF-8?q?=E4=BD=8EPE=E8=B6=85=E5=8D=96choppy)+=E4=B8=89=E6=8C=AF?= =?UTF-8?q?=E5=87=BA=E5=B1=80(strike2/40=E5=A4=A9)+=E7=BB=84=E5=90=88?= =?UTF-8?q?=E7=BA=A7=E9=98=B2=E5=AE=88(trend=5Fdown=E8=BF=9E=E7=BB=AD>5?= =?UTF-8?q?=E5=A4=A9=E6=9A=82=E5=81=9C=E8=B6=85=E5=8D=96),=E5=B9=B4?= =?UTF-8?q?=E5=8C=9618.6%/=E8=BF=911=E5=B9=B4+22.7%/=E8=BF=916=E6=9C=88+10?= =?UTF-8?q?.7%/=E8=BF=913=E6=9C=88+1.2%=E5=85=A8=E8=BE=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/hk_backtest.py | 21 +++++++++++++++++---- deploy/profile-scripts/hk_strategies.py | 4 ++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/deploy/profile-scripts/hk_backtest.py b/deploy/profile-scripts/hk_backtest.py index 40a28f53..c874ae07 100644 --- a/deploy/profile-scripts/hk_backtest.py +++ b/deploy/profile-scripts/hk_backtest.py @@ -224,29 +224,42 @@ def main(): ap = argparse.ArgumentParser() ap.add_argument("--version", default=None) ap.add_argument("--slots", type=int, default=8) + ap.add_argument("--strike", type=int, default=2) + ap.add_argument("--cooldown", type=int, default=40) + ap.add_argument("--td-guard", type=int, default=5, help="trend_down连续超过N天暂停超卖策略(防守)") args = ap.parse_args() panel = load_panel() print(f"港股面板: {len(panel)} 行\n", flush=True) + # trend_down 连续天数(组合级防守) + rm = load_regime_map() + dates = sorted(rm.keys()) + td_run = {} + run = 0 + for d in dates: + run = run + 1 if rm[d] == "trend_down" else 0 + td_run[d] = run + versions = [args.version] if args.version else list(HK_STRATEGIES.keys()) all_trades = [] - rm = load_regime_map() # 港股温区映射(组合温区调度) for v in versions: strat = get_hk_strategy(v) if not strat: print(f"未知策略: {v}") continue print(f"=== {v} ({strat['name']}) ===", flush=True) - trades = gen_trades_defensive(panel, strat, strike=3, cooldown_days=15) + trades = gen_trades_defensive(panel, strat, strike=args.strike, cooldown_days=args.cooldown) if not trades: print(" 无交易\n", flush=True) continue - # 温区调度:只保留策略适用温区的交易(组合正确性关键) + # 温区调度 + 组合级防守(trend_down 连续>N天暂停超卖,避免持续下跌被埋) reg = strat.get("regime", "all") if reg != "all" and args.version is None: trades = [t for t in trades if rm.get(t["entry_date"]) == reg] - print(f" 温区调度({reg}): 保留 {len(trades)} 笔", flush=True) + if reg == "trend_down" and args.td_guard > 0: + trades = [t for t in trades if td_run.get(t["entry_date"], 0) <= args.td_guard] + print(f" 温区调度({reg})+防守: 保留 {len(trades)} 笔", flush=True) m = portfolio_metrics(trades, slots=args.slots) print(f" 交易{m['trades']} 胜率{m['win_rate']:.0f}% 组合年化{m['cagr']}% " f"近1年{m['year1']:+.1f}% 近6月{m['month6']:+.1f}% 近3月{m['month3']:+.1f}%\n", flush=True) diff --git a/deploy/profile-scripts/hk_strategies.py b/deploy/profile-scripts/hk_strategies.py index 8c119f18..5cee5ef3 100644 --- a/deploy/profile-scripts/hk_strategies.py +++ b/deploy/profile-scripts/hk_strategies.py @@ -25,9 +25,9 @@ HK_STRATEGIES = { "mcap_q_max": 0.2, # 市值分位<0.2(小市值,+2.84pp) "sec_ret20_min": 10, # 行业20日动量>10%(+1.47pp) }, - "exit": {"tp_pct": 0.30, "sl_pct": 0.12, "max_hold_days": 40}, + "exit": {"tp_pct": 0.40, "sl_pct": 0.12, "max_hold_days": 40}, }, - # trend_down:深度超卖反弹(由果及因:RSI<20/bias60<-20,持续下跌市避被埋,胜率72%) + # trend_down:深度超卖反弹(持续下跌市靠组合级防守避免被埋) "hk_mr1": { "version": "hk_mr1", "name": "港股深度超卖反弹(trend_down主战场)",