feat(market_scanner): 优化回退信号逻辑以提升信号处理能力

在市场扫描逻辑中调整了回退信号的计算方式,降低了信号强度为零时的触发条件,并引入24小时涨跌幅作为方向判断依据。这一改动旨在增强策略的灵活性,确保在市场波动时能够提供更有效的交易建议,同时提升用户体验。
This commit is contained in:
薇薇安 2026-02-25 13:45:36 +08:00
parent d1c560ae16
commit 09edc4f57d

View File

@ -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: