fix tp
This commit is contained in:
parent
278015d0b1
commit
f45cb3c152
@ -516,29 +516,39 @@ class BitgetTradingAPI:
|
||||
if take_profit:
|
||||
tp_side = 'sell' if pos_side == 'long' else 'buy'
|
||||
try:
|
||||
# 使用普通的 create_order 创建止盈限价单
|
||||
if self.use_unified_account:
|
||||
# UTA 模式:用 takeProfitPrice 触发策略订单路由
|
||||
# CCXT 通过 takeProfitPrice 判断是否走 privateUtaPostV3TradePlaceStrategyOrder
|
||||
tp_params = {
|
||||
'takeProfitPrice': take_profit,
|
||||
'hedged': True,
|
||||
'reduceOnly': True,
|
||||
'marginCoin': 'USDT',
|
||||
}
|
||||
tp_order = self.exchange.create_order(
|
||||
symbol=ccxt_symbol,
|
||||
type='market',
|
||||
side=tp_side,
|
||||
amount=btc_amount,
|
||||
params=self._with_account_mode_params(tp_params),
|
||||
)
|
||||
else:
|
||||
# 经典账户:普通限价止盈单
|
||||
tp_params = {
|
||||
'tdMode': 'cross',
|
||||
'marginCoin': 'USDT',
|
||||
'reduceOnly': True,
|
||||
}
|
||||
tp_order = self.exchange.create_order(
|
||||
symbol=ccxt_symbol,
|
||||
type='limit',
|
||||
side=tp_side,
|
||||
amount=btc_amount,
|
||||
price=take_profit,
|
||||
params=self._with_account_mode_params(tp_params),
|
||||
)
|
||||
tp_order = self.exchange.create_order(
|
||||
symbol=ccxt_symbol,
|
||||
type='limit',
|
||||
side=tp_side,
|
||||
amount=btc_amount,
|
||||
price=take_profit,
|
||||
params=tp_params,
|
||||
)
|
||||
orders_created.append(('止盈', tp_order))
|
||||
logger.info(f"✅ 止盈单已下: {tp_side} {btc_amount} BTC @ ${take_profit}")
|
||||
logger.info(f"✅ 止盈单已下: {tp_side} {btc_amount} @ ${take_profit}")
|
||||
except Exception as e:
|
||||
logger.warning(f"下止盈单失败: {e}")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user