This commit is contained in:
薇薇安 2026-01-25 11:04:50 +08:00
parent 10fd7a7d60
commit 096b838769

View File

@ -1199,8 +1199,9 @@ class PositionManager:
if side == "BUY": if side == "BUY":
# 做多:当前价 <= 止损价,说明已触发止损 # 做多:当前价 <= 止损价,说明已触发止损
if current_price_val <= stop_loss_val: if current_price_val <= stop_loss_val:
entry_price_str = f"{entry_price_val:.8f}" if entry_price_val is not None else 'N/A'
logger.error(f"{symbol} ⚠️ 当前价格({current_price_val:.8f})已触发止损价({stop_loss_val:.8f}),无法挂止损单,立即执行市价平仓保护!") logger.error(f"{symbol} ⚠️ 当前价格({current_price_val:.8f})已触发止损价({stop_loss_val:.8f}),无法挂止损单,立即执行市价平仓保护!")
logger.error(f" 入场价: {entry_price_val:.8f if entry_price_val else 'N/A'}") logger.error(f" 入场价: {entry_price_str}")
# 立即执行市价平仓 # 立即执行市价平仓
await self.close_position(symbol, reason='stop_loss') await self.close_position(symbol, reason='stop_loss')
return return
@ -1216,8 +1217,9 @@ class PositionManager:
elif side == "SELL": elif side == "SELL":
# 做空:当前价 >= 止损价,说明已触发止损 # 做空:当前价 >= 止损价,说明已触发止损
if current_price_val >= stop_loss_val: if current_price_val >= stop_loss_val:
entry_price_str = f"{entry_price_val:.8f}" if entry_price_val is not None else 'N/A'
logger.error(f"{symbol} ⚠️ 当前价格({current_price_val:.8f})已触发止损价({stop_loss_val:.8f}),无法挂止损单,立即执行市价平仓保护!") logger.error(f"{symbol} ⚠️ 当前价格({current_price_val:.8f})已触发止损价({stop_loss_val:.8f}),无法挂止损单,立即执行市价平仓保护!")
logger.error(f" 入场价: {entry_price_val:.8f if entry_price_val else 'N/A'}") logger.error(f" 入场价: {entry_price_str}")
# 立即执行市价平仓 # 立即执行市价平仓
await self.close_position(symbol, reason='stop_loss') await self.close_position(symbol, reason='stop_loss')
return return