Fixed the function of setting TP and SL

This commit is contained in:
algizn97
2025-11-02 17:14:22 +05:00
parent dbf0a30d54
commit e0167ea406
2 changed files with 10 additions and 9 deletions

View File

@@ -25,11 +25,13 @@ async def set_tp_sl_for_position(
"""
try:
client = await get_bybit_client(tg_id)
take_profit = round(take_profit_price, 6) if take_profit_price is not None else None
stop_loss = round(stop_loss_price, 6) if stop_loss_price is not None else None
resp = client.set_trading_stop(
category="linear",
symbol=symbol,
takeProfit=str(round(take_profit_price, 5)),
stopLoss=str(round(stop_loss_price, 5)),
takeProfit=str(take_profit) if take_profit is not None else None,
stopLoss=str(stop_loss) if stop_loss is not None else None,
positionIdx=position_idx,
tpslMode="Full",
)