From 10fd7a7d6022e21759d61ad2ffd770f544971420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=87=E8=96=87=E5=AE=89?= Date: Sun, 25 Jan 2026 10:59:34 +0800 Subject: [PATCH] a --- trading_system/risk_manager.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/trading_system/risk_manager.py b/trading_system/risk_manager.py index 4d2f924..98e5f34 100644 --- a/trading_system/risk_manager.py +++ b/trading_system/risk_manager.py @@ -681,14 +681,17 @@ class RiskManager: if stop_loss_price_price is not None: candidate_prices.append(('价格百分比', stop_loss_price_price)) - # 选择“更宽松/更远”的止损: - # - 做多(BUY):止损越低越宽松 → 取最小值 - # - 做空(SELL):止损越高越宽松 → 取最大值 + # ⚠️ 修复:选择"更紧的止损"(更接近入场价),保护资金 + # - 做多(BUY):止损价越低越紧(更接近入场价)→ 取最大值(更高的止损价,更接近入场价) + # - 做空(SELL):止损价越高越紧(更接近入场价)→ 取最小值(更低的止损价,更接近入场价) + # 注意:做空时,止损价高于入场价,所以"更紧"意味着"更小的止损价"(更接近入场价) if side == 'BUY': - stop_loss_price = min(p[1] for p in candidate_prices) + # 做多:止损价越低越紧 → 取最大值(更高的止损价,更接近入场价) + stop_loss_price = max(p[1] for p in candidate_prices) selected_method = [p[0] for p in candidate_prices if p[1] == stop_loss_price][0] else: - stop_loss_price = max(p[1] for p in candidate_prices) + # 做空:止损价越高越紧 → 取最小值(更低的止损价,更接近入场价) + stop_loss_price = min(p[1] for p in candidate_prices) selected_method = [p[0] for p in candidate_prices if p[1] == stop_loss_price][0] # 如果提供了技术分析数据,计算技术止损(允许更紧的止损,但需要在保证金止损范围内)