From 09edc4f57d90497ba7e8d9bb5d431cbc40e01fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=87=E8=96=87=E5=AE=89?= Date: Wed, 25 Feb 2026 13:45:36 +0800 Subject: [PATCH] =?UTF-8?q?feat(market=5Fscanner):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=9B=9E=E9=80=80=E4=BF=A1=E5=8F=B7=E9=80=BB=E8=BE=91=E4=BB=A5?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E4=BF=A1=E5=8F=B7=E5=A4=84=E7=90=86=E8=83=BD?= =?UTF-8?q?=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在市场扫描逻辑中调整了回退信号的计算方式,降低了信号强度为零时的触发条件,并引入24小时涨跌幅作为方向判断依据。这一改动旨在增强策略的灵活性,确保在市场波动时能够提供更有效的交易建议,同时提升用户体验。 --- trading_system/market_scanner.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/trading_system/market_scanner.py b/trading_system/market_scanner.py index 007f69e..3d4e7e0 100644 --- a/trading_system/market_scanner.py +++ b/trading_system/market_scanner.py @@ -854,9 +854,10 @@ class MarketScanner: # 强度上限归一到 0-10 signal_strength = max(0, min(int(signal_strength), 10)) - # 回退:趋势逻辑过严时(MACD/EMA/4H 未同时满足),用 RSI/MACD/布林 综合得分给弱信号,避免长期全 0 - if signal_strength == 0 and direction is None and signal_score >= 5: - fallback_strength = min(5, max(1, signal_score - 3)) # 5->2, 6->3, 7->4, 8+->5 + # 回退:趋势逻辑过严时(MACD/EMA/4H 未同时满足),用 RSI/MACD/布林/涨跌 给弱信号,避免长期全 0 + # 强度映射:signal_score 4->2, 5->3, 6->4, 7->5, 8->6, 9->7, 10->7(高得分可触达 MIN_SIGNAL_STRENGTH 7) + if signal_strength == 0 and direction is None and signal_score >= 4: + fallback_strength = min(7, max(2, signal_score - 2)) if rsi is not None: if rsi < 35: direction = 'BUY' @@ -885,6 +886,17 @@ class MarketScanner: elif current_price < ema20 < ema50: direction = 'SELL' signal_strength = fallback_strength + # 仍无方向时用 24h 涨跌给方向(便于出推荐/开单;强度用 fallback_strength,高得分可≥7) + if direction is None: + change_pct = symbol_info.get('changePercent') + try: + ch = float(change_pct) if change_pct is not None else None + except (TypeError, ValueError): + ch = None + if ch is not None: + direction = 'BUY' if ch > 0.5 else ('SELL' if ch < -0.5 else None) + if direction: + signal_strength = fallback_strength # ===== 趋势状态缓存(用于后续“入场时机过滤”)===== try: