From 9497cca3e0b05f19f5fc0fd8f45a1b59064c68b4 Mon Sep 17 00:00:00 2001 From: algizn97 Date: Mon, 27 Oct 2025 13:05:19 +0500 Subject: [PATCH] Switched to demo mode --- app/bybit/__init__.py | 2 +- app/bybit/open_positions.py | 4 +++- app/bybit/telegram_message_handler.py | 4 ---- app/bybit/web_socket.py | 4 +++- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/bybit/__init__.py b/app/bybit/__init__.py index 7b4197e..2ca741b 100644 --- a/app/bybit/__init__.py +++ b/app/bybit/__init__.py @@ -15,7 +15,7 @@ async def get_bybit_client(tg_id: int) -> HTTP | None: """ try: api_key, api_secret = await rq.get_user_api(tg_id=tg_id) - return HTTP(api_key=api_key, api_secret=api_secret) + return HTTP(demo=True, api_key=api_key, api_secret=api_secret) except Exception as e: logger.error("Error getting bybit client for user %s: %s", tg_id, e) return None diff --git a/app/bybit/open_positions.py b/app/bybit/open_positions.py index 717460d..ed233d6 100644 --- a/app/bybit/open_positions.py +++ b/app/bybit/open_positions.py @@ -152,11 +152,13 @@ async def trading_cycle_profit( else: s_side = side + next_series = current_series + 1 + await rq.set_user_deal( tg_id=tg_id, symbol=symbol, current_step=1, - current_series=current_series, + current_series=next_series, trade_mode=trade_mode, side_mode=side_mode, margin_type=margin_type, diff --git a/app/bybit/telegram_message_handler.py b/app/bybit/telegram_message_handler.py index 2315178..94f84d4 100644 --- a/app/bybit/telegram_message_handler.py +++ b/app/bybit/telegram_message_handler.py @@ -190,10 +190,6 @@ class TelegramMessageHandler: res = await trading_cycle_profit( tg_id=tg_id, symbol=symbol, side=r_side ) - current_series += 1 - await rq.set_current_series( - tg_id=tg_id, symbol=symbol, current_series=current_series - ) if res == "OK": pass else: diff --git a/app/bybit/web_socket.py b/app/bybit/web_socket.py index 4c3579f..c937510 100644 --- a/app/bybit/web_socket.py +++ b/app/bybit/web_socket.py @@ -58,7 +58,8 @@ class WebSocketBot: ) logger.info("User %s connected to WebSocket", tg_id) else: - await asyncio.sleep(30) + await asyncio.sleep(5) + await self.try_connect_user(api_key, api_secret, tg_id) await asyncio.sleep(10) @@ -73,6 +74,7 @@ class WebSocketBot: """Try to connect a user to the WebSocket.""" try: self.ws_private = WebSocket( + demo=True, testnet=False, channel_type="private", api_key=api_key,