优化亏损交易策略

This commit is contained in:
薇薇安 2026-02-03 11:26:46 +08:00
parent cc6750fa47
commit 040473d4d3
2 changed files with 36 additions and 14 deletions

View File

@ -425,11 +425,21 @@ class MarketScanner:
if ema20 and ema50:
if current_price > ema20 > ema50: # 上升趋势
if trend_4h in ('up', 'neutral', None):
# 冲突检查
if direction == 'SELL':
signal_strength = 0
direction = None
else:
signal_strength += TREND_SIGNAL_WEIGHTS['ema_cross']
if direction is None:
direction = 'BUY'
elif current_price < ema20 < ema50: # 下降趋势
if trend_4h in ('down', 'neutral', None):
# 冲突检查
if direction == 'BUY':
signal_strength = 0
direction = None
else:
signal_strength += TREND_SIGNAL_WEIGHTS['ema_cross']
if direction is None:
direction = 'SELL'

View File

@ -440,6 +440,12 @@ class TradingStrategy:
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:
@ -451,6 +457,12 @@ class TradingStrategy:
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: