1
This commit is contained in:
parent
7abf7db2df
commit
c4a23be3bf
|
|
@ -2952,6 +2952,11 @@ class PositionManager:
|
||||||
"leverage": lev, "entryReason": "sync_recovered", "atr": None, "maxProfit": 0.0, "trailingStopActivated": False,
|
"leverage": lev, "entryReason": "sync_recovered", "atr": None, "maxProfit": 0.0, "trailingStopActivated": False,
|
||||||
}
|
}
|
||||||
self.active_positions[symbol] = position_info
|
self.active_positions[symbol] = position_info
|
||||||
|
# 补建后立即在交易所挂/修正止损止盈(替换可能存在的异常远止损、缺止盈等)
|
||||||
|
try:
|
||||||
|
await self._ensure_exchange_sltp_orders(symbol, position_info, current_price=current_price)
|
||||||
|
except Exception as sltp_e:
|
||||||
|
logger.warning(f" {symbol} [补建] 补挂交易所止损止盈失败(不影响监控): {sltp_e}")
|
||||||
if self._monitoring_enabled:
|
if self._monitoring_enabled:
|
||||||
await self._start_position_monitoring(symbol)
|
await self._start_position_monitoring(symbol)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -3221,6 +3226,19 @@ class PositionManager:
|
||||||
logger.warning(f"{symbol} 补挂币安止盈止损失败(不影响监控): {e}")
|
logger.warning(f"{symbol} 补挂币安止盈止损失败(不影响监控): {e}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"{symbol} 创建临时持仓记录失败: {e}")
|
logger.error(f"{symbol} 创建临时持仓记录失败: {e}")
|
||||||
|
else:
|
||||||
|
# 已在 active_positions 的持仓:启动前统一补挂/修正交易所 SL/TP(识别缺止盈、止损过远等异常并替换)
|
||||||
|
position_info = self.active_positions.get(symbol)
|
||||||
|
if position_info and position_info.get("stopLoss") and position_info.get("takeProfit"):
|
||||||
|
try:
|
||||||
|
mp = None
|
||||||
|
try:
|
||||||
|
mp = float(position.get("markPrice", 0) or 0) or None
|
||||||
|
except Exception:
|
||||||
|
mp = None
|
||||||
|
await self._ensure_exchange_sltp_orders(symbol, position_info, current_price=mp)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"{symbol} 补挂/修正交易所止损止盈失败(不影响监控): {e}")
|
||||||
|
|
||||||
await self._start_position_monitoring(symbol)
|
await self._start_position_monitoring(symbol)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user