diff --git a/app/bybit/telegram_message_handler.py b/app/bybit/telegram_message_handler.py index db92bcb..084dcf0 100644 --- a/app/bybit/telegram_message_handler.py +++ b/app/bybit/telegram_message_handler.py @@ -89,8 +89,6 @@ class TelegramMessageHandler: tg_id=tg_id, symbol=symbol, fee=safe_float(exec_fee) ) - - get_total_fee = user_auto_trading.total_fee total_fee = safe_float(exec_fee) + safe_float(get_total_fee) @@ -177,19 +175,23 @@ class TelegramMessageHandler: take_profit_price = max(take_profit_price, 0) stop_loss_price = max(stop_loss_price, 0) - await set_tp_sl_for_position(tg_id=tg_id, - symbol=symbol, - take_profit_price=take_profit_price, - stop_loss_price=stop_loss_price, - position_idx=0) + ress = await set_tp_sl_for_position(tg_id=tg_id, + symbol=symbol, + take_profit_price=take_profit_price, + stop_loss_price=stop_loss_price, + position_idx=0) + if ress: + take_profit_truncated = await truncate_float(take_profit_price, 6) + stop_loss_truncated = await truncate_float(stop_loss_price, 6) - take_profit_truncated = await truncate_float(take_profit_price, 6) - stop_loss_truncated = await truncate_float(stop_loss_price, 6) + text += (f"Движение: {side_rus}\n" + f"Тейк-профит: {take_profit_truncated}\n" + f"Стоп-лосс: {stop_loss_truncated}\n" + ) + else: + text += (f"Движение: {side_rus}\n" + "Не удалось установить ТП и СЛ\n") - text += (f"Движение: {side_rus}\n" - f"Тейк-профит: {take_profit_truncated}\n" - f"Стоп-лосс: {stop_loss_truncated}\n" - ) else: new_pnl = safe_float(pnl_series) + total_pnl await rq.set_pnl_series_by_symbol( @@ -205,9 +207,9 @@ class TelegramMessageHandler: user_symbols = user_auto_trading.symbol if user_auto_trading else None if ( - auto_trading - and safe_float(closed_size) > 0 - and user_symbols is not None + auto_trading + and safe_float(closed_size) > 0 + and user_symbols is not None ): if safe_float(pnl) > 0: profit_text = "📈 Начинаю новую серию с базовой ставки\n"