From 090a5afc91f753a99a2445b2539a3b3b72c071da Mon Sep 17 00:00:00 2001 From: hmo Date: Thu, 30 Jul 2026 09:38:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=89=E7=BA=A7=E8=B6=8B=E5=8A=BF?= =?UTF-8?q?=E5=BC=BA=E5=8C=96=E2=80=94=E2=80=94=E5=A4=A7=E7=9B=98ADX?= =?UTF-8?q?=E2=89=A520=E8=BF=9B=5FV40=5FBASE=E5=85=A8=E5=AE=B6=E6=97=8F?= =?UTF-8?q?=E7=BB=A7=E6=89=BF,=E8=BF=87=E6=BB=A4MA20=E4=B8=8A=E4=BD=86?= =?UTF-8?q?=E8=B6=8B=E5=8A=BF=E5=BC=B1=E7=9A=84=E5=81=87=E7=89=9B=E5=B8=82?= =?UTF-8?q?=E6=97=A5(v9.2=E9=9C=87=E8=8D=A1=E5=B9=B40=E7=AC=94/v8.1?= =?UTF-8?q?=E7=89=9B=E5=B8=82100%=E5=85=A8=E8=83=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- strategy_lab.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/strategy_lab.py b/strategy_lab.py index 02a2db49..5ca4ec37 100644 --- a/strategy_lab.py +++ b/strategy_lab.py @@ -84,7 +84,7 @@ STRATEGIES = { "dist_ma20_min": 4, "vol_ratio_min": 1.2, "vol_ratio_max": 1.5, "ma20_slope_max": 1.5, - "mkt_above_ma20": True, "mkt_slope_max": -0.05, + "mkt_above_ma20": True, "mkt_slope_max": -0.05, "mkt_adx_min": 20, "hh_only": True}}, "exit": {"tp_pct": 0.15, "sl_atr": 1.5, "max_hold_days": 20}, "sizing": {"kelly": True, "kelly_fraction": 0.5}, @@ -380,6 +380,7 @@ def _load_index_ctx(index_code, start_date, end_date): 'above_ma20': (b.get('close') or 0) > ma20 if ma20 > 0 else None, 'ma20_slope': slope, 'roc': b.get('roc'), + 'adx': b.get('adx'), # 趋势强度(choppy市<20,趋势市>25,2026-07-30强化趋势过滤) } return ctx @@ -594,6 +595,7 @@ def pass_filters(factors, filters): # 大盘 if filters.get('mkt_above_ma20') and factors.get('mkt_above_ma20') is not True: return False if not chk('mkt_slope', filters.get('mkt_slope_min'), filters.get('mkt_slope_max')): return False + if not chk('mkt_adx', filters.get('mkt_adx_min'), filters.get('mkt_adx_max')): return False # 行业 if not chk('sector_change', filters.get('sector_change_min'), filters.get('sector_change_max')): return False if not chk('sector_rank_pct', None, filters.get('sector_rank_pct_max')): return False @@ -741,6 +743,7 @@ def run_backtest(strategy_version, start_date, end_date, capital=1000000, save=T factors['mkt_above_ma20'] = mk.get('above_ma20') factors['mkt_slope'] = mk.get('ma20_slope') factors['mkt_roc'] = mk.get('roc') + factors['mkt_adx'] = mk.get('adx') factors['sector_change'] = sc_ctx.get('change') factors['sector_rank_pct'] = sc_ctx.get('rank_pct') factors['sector_inflow'] = sc_ctx.get('inflow')