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