This commit is contained in:
aaron 2026-02-26 09:39:34 +08:00
parent dc44b2aa4a
commit 5271976956

View File

@ -245,8 +245,8 @@ class PaperTradingService:
if quantity_from_signal is not None and quantity_from_signal > 0: if quantity_from_signal is not None and quantity_from_signal > 0:
# LLM 决策的 quantity 是保证金金额 # LLM 决策的 quantity 是保证金金额
margin = float(quantity_from_signal) margin = float(quantity_from_signal)
# 计算持仓价值(保证金 × 杠杆) # 计算持仓价值(保证金 × 杠杆)保留2位小数
position_value = margin * self.leverage position_value = round(margin * self.leverage, 2)
logger.debug(f"使用 LLM 决策保证金: ${margin:.2f}, 持仓价值: ${position_value:.2f}") logger.debug(f"使用 LLM 决策保证金: ${margin:.2f}, 持仓价值: ${position_value:.2f}")
else: else:
# 回退到动态仓位计算 # 回退到动态仓位计算
@ -259,7 +259,7 @@ class PaperTradingService:
result['message'] = msg result['message'] = msg
return result return result
quantity = position_value # 订单数量(以 USDT 计价) quantity = round(position_value, 2) # 确保持仓价值保留2位小数
# 确定入场类型 # 确定入场类型
entry_type_str = signal.get('entry_type', 'market') entry_type_str = signal.get('entry_type', 'market')