This commit is contained in:
薇薇安 2026-01-28 10:13:30 +08:00
parent dfd899256b
commit 3865e25a2b
3 changed files with 26 additions and 6 deletions

View File

@ -222,13 +222,13 @@ def _get_trading_config():
'MIN_VOLUME_24H': 30000000, # 24小时成交额≥3000万美元过滤垃圾币
'MIN_VOLUME_24H_STRICT': 50000000, # 严格过滤≥5000万美元
'MIN_VOLATILITY': 0.03, # 最小波动率3%,过滤死币
'MIN_SIGNAL_STRENGTH': 7, # 信号强度≥72026-01-27优化提高门槛,减少垃圾信号,提升胜率)
'MIN_SIGNAL_STRENGTH': 9, # 信号强度≥92026-01-28优化大幅提高门槛,减少垃圾信号,提升胜率)
# ===== 动态过滤优化 =====
'BETA_FILTER_ENABLED': True, # 大盘共振过滤BTC/ETH下跌时屏蔽多单
'BETA_FILTER_THRESHOLD': -0.005, # -0.5%2026-01-27优化更敏感地过滤大盘风险15分钟内跌幅超过0.5%即屏蔽多单)
'ATR_SPIKE_THRESHOLD': 2.0, # ATR异常激增阈值当前ATR / 平均ATR
'SIGNAL_STRENGTH_POSITION_MULTIPLIER': {8: 0.5, 9: 1.0, 10: 1.0}, # 信号强度分级:8分50%仓位,9-10分100%仓位
'SIGNAL_STRENGTH_POSITION_MULTIPLIER': {9: 1.0, 10: 1.0}, # 信号强度分级:9-10分100%仓位2026-01-28优化最低信号强度已提高到9
# ===== 仓位管理优化(山寨币专属)=====
'USE_FIXED_RISK_SIZING': True, # 固定每笔风险,避免亏损扩大
@ -256,8 +256,8 @@ def _get_trading_config():
# ===== 智能入场方案C=====
# 根治方案:默认关闭。关闭后回归“纯限价单模式”(不追价/不市价兜底/未成交撤单跳过)
'SMART_ENTRY_ENABLED': True, # 开启智能入场,提高成交率
'SMART_ENTRY_STRONG_SIGNAL': 7, # 强信号阈值≥7
'ENTRY_SYMBOL_COOLDOWN_SEC': 1800, # 同一币种冷却30分钟1800秒避免频繁操作
'SMART_ENTRY_STRONG_SIGNAL': 9, # 强信号阈值≥92026-01-28优化与MIN_SIGNAL_STRENGTH保持一致
'ENTRY_SYMBOL_COOLDOWN_SEC': 3600, # 同一币种冷却60分钟3600秒避免频繁操作2026-01-28优化减少同一交易对反复开仓
'ENTRY_TIMEOUT_SEC': 180, # 智能入场总预算(秒)(限价/追价逻辑内部使用)
'ENTRY_STEP_WAIT_SEC': 15, # 每步等待成交时间(秒)
'ENTRY_CHASE_MAX_STEPS': 4, # 最多追价步数(逐步减少 offset

View File

@ -292,9 +292,11 @@ class TechnicalIndicators:
volatility_pct = (volatility / avg_price) * 100 if avg_price > 0 else 0
# 如果短期均线明显高于或低于长期均线,且波动率较大,判断为趋势
# ⚠️ 2026-01-28优化提高trending判断阈值确保只在真正的趋势市判断为trending
ma_diff_pct = abs(short_ma - long_ma) / long_ma * 100 if long_ma > 0 else 0
if ma_diff_pct > 2 and volatility_pct > 1:
# 提高阈值均线差异从2%提高到3.5%波动率从1%提高到1.5%
if ma_diff_pct > 3.5 and volatility_pct > 1.5:
return 'trending'
else:
return 'ranging'

View File

@ -759,13 +759,31 @@ class RiskManager:
final_stop_loss = min(p[1] for p in candidate_prices)
selected_method = [p[0] for p in candidate_prices if p[1] == final_stop_loss][0]
# ⚠️ 关键修复:验证最终止损价对应的保证金百分比不超过配置值
if side == 'BUY':
final_stop_loss_amount = (entry_price - final_stop_loss) * quantity
else:
final_stop_loss_amount = (final_stop_loss - entry_price) * quantity
final_stop_loss_pct_margin = (final_stop_loss_amount / margin * 100) if margin > 0 else 0
# 如果最终止损价对应的保证金百分比超过配置值,强制使用保证金止损
if final_stop_loss_pct_margin > (stop_loss_percent * 100):
logger.warning(
f"⚠️ 最终止损价({final_stop_loss:.4f}, 使用{selected_method})对应的保证金百分比({final_stop_loss_pct_margin:.2f}%) "
f"超过配置值({stop_loss_percent*100:.1f}%),强制使用保证金止损({stop_loss_price_margin:.4f})"
)
final_stop_loss = stop_loss_price_margin
selected_method = '保证金(强制)'
final_stop_loss_pct_margin = stop_loss_percent * 100
logger.info(
f"最终止损 ({side}): {final_stop_loss:.4f} (使用{selected_method}), "
+ (f"ATR={stop_loss_price_atr:.4f}, " if stop_loss_price_atr else "")
+ f"保证金={stop_loss_price_margin:.4f}, "
+ (f"价格={stop_loss_price_price:.4f}, " if stop_loss_price_price else "")
+ (f"技术={technical_stop:.4f}, " if technical_stop else "")
+ f"止损金额={stop_loss_amount:.2f} USDT ({stop_loss_percent*100:.1f}% of margin)"
+ f"止损金额={stop_loss_amount:.2f} USDT ({stop_loss_percent*100:.1f}% of margin), "
+ f"实际保证金百分比={final_stop_loss_pct_margin:.2f}%"
)
return final_stop_loss