1
This commit is contained in:
parent
784c6a8fff
commit
e933784555
@ -146,6 +146,11 @@ class BaseExecutor(ABC):
|
||||
now = datetime.now()
|
||||
|
||||
for order in pending_orders:
|
||||
if order.get('is_reduce_only'):
|
||||
continue
|
||||
if str(order.get('order_type') or '').lower() == 'uta_tpsl':
|
||||
continue
|
||||
|
||||
created_at = order.get('created_at')
|
||||
if not created_at:
|
||||
continue
|
||||
|
||||
@ -577,7 +577,12 @@ class BitgetLiveTradingService:
|
||||
"message": "订单已不在挂单列表,可能已成交、已撤销或已失效",
|
||||
}
|
||||
|
||||
success = self.trading_api.cancel_order(symbol=symbol, order_id=order_id)
|
||||
order_type = str(matched_order.get('order_type') or '').lower()
|
||||
if order_type == 'uta_tpsl':
|
||||
success = self.trading_api.cancel_strategy_order(symbol=symbol, order_id=order_id)
|
||||
else:
|
||||
success = self.trading_api.cancel_order(symbol=symbol, order_id=order_id)
|
||||
|
||||
if success:
|
||||
logger.info(f"✅ Bitget 单笔撤单成功: {symbol} #{order_id}")
|
||||
return {"success": True, "order_id": normalized_order_id, "symbol": symbol}
|
||||
|
||||
@ -222,6 +222,37 @@ class BitgetTradingAPI:
|
||||
logger.error(f"❌ 撤单异常: {e}")
|
||||
return False
|
||||
|
||||
def cancel_strategy_order(self, symbol: str, order_id: str) -> bool:
|
||||
"""
|
||||
撤销 UTA 未触发策略单(TP/SL 等)。
|
||||
|
||||
Args:
|
||||
symbol: 交易对
|
||||
order_id: 策略单 ID
|
||||
|
||||
Returns:
|
||||
是否成功
|
||||
"""
|
||||
try:
|
||||
payload = {
|
||||
'category': self.DEFAULT_PRODUCT_TYPE,
|
||||
'symbol': self._to_contract_symbol_id(symbol),
|
||||
'orderId': str(order_id),
|
||||
}
|
||||
response = self.exchange.privateUtaPostV3TradeCancelStrategyOrder(payload)
|
||||
if response.get('code') not in (None, '00000'):
|
||||
logger.error(f"❌ 撤销策略单失败: {response}")
|
||||
return False
|
||||
|
||||
logger.info(f"✅ 撤销策略单成功: {symbol} order_id={order_id}")
|
||||
return True
|
||||
except ccxt.BaseError as e:
|
||||
logger.error(f"❌ 撤销策略单失败: {e}")
|
||||
return False
|
||||
except Exception as e:
|
||||
logger.error(f"❌ 撤销策略单异常: {e}")
|
||||
return False
|
||||
|
||||
def cancel_all_orders(self, symbol: str) -> bool:
|
||||
"""
|
||||
撤销所有挂单
|
||||
|
||||
Loading…
Reference in New Issue
Block a user