diff --git a/trading_system/position_manager.py b/trading_system/position_manager.py index 089d529..5026b30 100644 --- a/trading_system/position_manager.py +++ b/trading_system/position_manager.py @@ -3956,16 +3956,18 @@ class PositionManager: for position in positions: symbol = position['symbol'] if symbol not in self._monitor_tasks: - # 若不在 active_positions:要么开启「同步创建手动开仓」则全部接入,要么仅对「有止损/止盈单」的接入(视为系统单) + # 若不在 active_positions:开启「同步创建手动开仓」则全部接入;或开启「监控仅币安有仓」时也接入(有 SL/TP 的视为系统单,无 SL/TP 的补挂并监控,避免裸仓) if symbol not in self.active_positions: has_sltp = await self._symbol_has_sltp_orders(symbol) if monitor_binance_with_sltp else False - should_create = sync_create_manual or (monitor_binance_with_sltp and has_sltp) + should_create = sync_create_manual or monitor_binance_with_sltp if not should_create: continue if sync_create_manual: logger.warning(f"[账号{self.account_id}] {symbol} 在币安有持仓但不在本地记录中,可能是手动开仓,尝试创建记录...") - else: + elif has_sltp: logger.info(f"[账号{self.account_id}] {symbol} 仅币安有仓且存在止损/止盈单,按系统单接入监控并补建记录") + else: + logger.info(f"[账号{self.account_id}] {symbol} 仅币安有仓且无止损/止盈单,接入监控并补挂 SL/TP(避免裸仓)") try: entry_price = position.get('entryPrice', 0) position_amt = position['positionAmt']