Fixed websocket #29

Merged
Arsen Mirzaev Tatyano-Muradovich merged 3 commits from Alex/stcs:devel into stable 2025-11-02 19:55:18 +07:00
4 changed files with 265 additions and 246 deletions
Showing only changes of commit e0167ea406 - Show all commits

View File

@@ -54,12 +54,6 @@ async def start_trading_cycle(
tg_id=tg_id,
symbol=symbol,
mode=0)
await set_margin_mode(tg_id=tg_id, margin_mode=margin_type)
await set_leverage(
tg_id=tg_id,
symbol=symbol,
leverage=leverage,
)
await rq.set_user_deal(
tg_id=tg_id,
@@ -316,7 +310,12 @@ async def open_positions(
try:
client = await get_bybit_client(tg_id=tg_id)
get_ticker = await get_tickers(tg_id, symbol=symbol)
price_symbol = safe_float(get_ticker.get("lastPrice")) or 0
if get_ticker is None:
price_symbol = 0
else:
price_symbol = safe_float(get_ticker.get("lastPrice"))
instruments_info = await get_instruments_info(tg_id=tg_id, symbol=symbol)
qty_step_str = instruments_info.get("lotSizeFilter").get("qtyStep")
qty_step = safe_float(qty_step_str)

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",
)