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: