From b4b001833ff9821e0132f8e639785d8a14eb60c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=87=E8=96=87=E5=AE=89?= Date: Fri, 6 Feb 2026 08:31:10 +0800 Subject: [PATCH] 1 --- trading_system/config.py | 6 ++-- trading_system/strategy.py | 68 ++++++++++++++++---------------------- update_strategy_config.py | 6 +++- 3 files changed, 36 insertions(+), 44 deletions(-) diff --git a/trading_system/config.py b/trading_system/config.py index ceabb10..f4254d7 100644 --- a/trading_system/config.py +++ b/trading_system/config.py @@ -199,9 +199,9 @@ def _get_trading_config(): 'MIN_POSITION_PERCENT': 0.01, # 最小仓位1% 'MIN_MARGIN_USDT': 5.0, # 最小保证金5美元 'MIN_CHANGE_PERCENT': 0.5, # 最小价格变动0.5% - 'TOP_N_SYMBOLS': 8, # 选择信号最强的8个优先处理 - 'SCAN_EXTRA_SYMBOLS_FOR_SUPPLEMENT': 8, # 智能补单:多返回8个候选,冷却时仍可尝试后续交易对 - 'MAX_SCAN_SYMBOLS': 250, # 扫描前250个(增加覆盖率,从27.6%提升到46.0%) + 'TOP_N_SYMBOLS': 20, # 选择信号最强的20个优先处理(2026-02-06优化:扩大候选池以捕获更多机会) + 'SCAN_EXTRA_SYMBOLS_FOR_SUPPLEMENT': 15, # 智能补单:多返回15个候选,冷却时仍可尝试后续交易对 + 'MAX_SCAN_SYMBOLS': 500, # 扫描前500个(覆盖所有交易对,确保不遗漏高波动币种) 'EXCLUDE_MAJOR_COINS': True, # 排除主流币(BTC、ETH、BNB等),专注于山寨币 'STOP_LOSS_PERCENT': 0.12, # 止损12%(保证金百分比) 'TAKE_PROFIT_PERCENT': 0.10, # 第二目标/单目标止盈10% diff --git a/trading_system/strategy.py b/trading_system/strategy.py index eb294c4..088f07b 100644 --- a/trading_system/strategy.py +++ b/trading_system/strategy.py @@ -407,14 +407,10 @@ class TradingStrategy: # MACD金叉,做多信号(严格4H趋势向上) # OPTIMIZATION: 允许明确向上趋势或中性趋势(如果是中性,后续需依靠高分信号确认) if trend_4h in ('up', 'neutral'): - # OPTIMIZATION: 添加 RSI 过滤,避免追高 - if rsi is None or rsi < 70: - signal_strength += TREND_SIGNAL_WEIGHTS['macd_cross'] - reasons.append("MACD金叉") - if direction is None: - direction = 'BUY' - else: - reasons.append(f"MACD金叉但RSI超买({rsi:.1f}),禁止追多") + signal_strength += TREND_SIGNAL_WEIGHTS['macd_cross'] + reasons.append("MACD金叉") + if direction is None: + direction = 'BUY' else: reasons.append(f"MACD金叉但4H趋势相反({trend_4h}),禁止逆势") @@ -422,14 +418,10 @@ class TradingStrategy: # MACD死叉,做空信号(严格4H趋势向下) # OPTIMIZATION: 允许明确向下趋势或中性趋势 if trend_4h in ('down', 'neutral'): - # OPTIMIZATION: 添加 RSI 过滤,避免杀跌 - if rsi is None or rsi > 30: - signal_strength += TREND_SIGNAL_WEIGHTS['macd_cross'] - reasons.append("MACD死叉") - if direction is None: - direction = 'SELL' - else: - reasons.append(f"MACD死叉但RSI超卖({rsi:.1f}),禁止追空") + signal_strength += TREND_SIGNAL_WEIGHTS['macd_cross'] + reasons.append("MACD死叉") + if direction is None: + direction = 'SELL' else: reasons.append(f"MACD死叉但4H趋势相反({trend_4h}),禁止逆势") @@ -438,35 +430,31 @@ class TradingStrategy: if current_price > ema20 > ema50: # 上升趋势 # OPTIMIZATION: 允许明确向上趋势或中性趋势 if trend_4h in ('up', 'neutral'): - # OPTIMIZATION: 添加 RSI 过滤 - if rsi is None or rsi < 70: - # 冲突检查:如果已有方向且与当前不符,则是严重冲突 - if direction == 'SELL': - reasons.append("❌ 信号冲突:MACD看空但EMA看多") - signal_strength = 0 - direction = None - else: - signal_strength += TREND_SIGNAL_WEIGHTS['ema_cross'] - reasons.append("EMA20上穿EMA50,上升趋势") - if direction is None: - direction = 'BUY' + # 冲突检查:如果已有方向且与当前不符,则是严重冲突 + if direction == 'SELL': + reasons.append("❌ 信号冲突:MACD看空但EMA看多") + signal_strength = 0 + direction = None + else: + signal_strength += TREND_SIGNAL_WEIGHTS['ema_cross'] + reasons.append("EMA20上穿EMA50,上升趋势") + if direction is None: + direction = 'BUY' else: reasons.append(f"1H均线向上但4H趋势相反({trend_4h}),禁止逆势") elif current_price < ema20 < ema50: # 下降趋势 # OPTIMIZATION: 允许明确向下趋势或中性趋势 if trend_4h in ('down', 'neutral'): - # OPTIMIZATION: 添加 RSI 过滤 - if rsi is None or rsi > 30: - # 冲突检查:如果已有方向且与当前不符,则是严重冲突 - if direction == 'BUY': - reasons.append("❌ 信号冲突:MACD看多但EMA看空") - signal_strength = 0 - direction = None - else: - signal_strength += TREND_SIGNAL_WEIGHTS['ema_cross'] - reasons.append("EMA20下穿EMA50,下降趋势") - if direction is None: - direction = 'SELL' + # 冲突检查:如果已有方向且与当前不符,则是严重冲突 + if direction == 'BUY': + reasons.append("❌ 信号冲突:MACD看多但EMA看空") + signal_strength = 0 + direction = None + else: + signal_strength += TREND_SIGNAL_WEIGHTS['ema_cross'] + reasons.append("EMA20下穿EMA50,下降趋势") + if direction is None: + direction = 'SELL' else: reasons.append(f"1H均线向下但4H趋势相反({trend_4h}),禁止逆势") diff --git a/update_strategy_config.py b/update_strategy_config.py index a1fec95..e0eeba5 100644 --- a/update_strategy_config.py +++ b/update_strategy_config.py @@ -16,7 +16,11 @@ try: ('ATR_TAKE_PROFIT_MULTIPLIER', 2.0, 'float', 'risk', 'ATR止盈倍数'), # Also ensure USE_ATR_STOP_LOSS is True ('USE_ATR_STOP_LOSS', True, 'bool', 'risk', '开启ATR止损'), - ] + # 2026-02-06 Optimization: Increase candidate pool + ('TOP_N_SYMBOLS', 20, 'int', 'scanner', '候选池大小(优化后20)'), + ('SCAN_EXTRA_SYMBOLS_FOR_SUPPLEMENT', 15, 'int', 'scanner', '补单候选池(优化后15)'), + ('MAX_SCAN_SYMBOLS', 500, 'int', 'scanner', '最大扫描数量(优化后500)'), + ] print("Updating Global Strategy Config...") for key, value, type_, category, desc in updates: