develop #3

Open
Alex wants to merge 77 commits from Alex/stcs:develop into stable
36 changed files with 2410 additions and 508 deletions
Showing only changes of commit 29a5df0b1a - Show all commits

24
app/tasks/tasks.py Normal file
View File

@@ -0,0 +1,24 @@
import asyncio
from app.services.Bybit.functions.Futures import close_trade_after_delay, trading_cycle
active_start_tasks = {}
active_close_tasks = {}
def start_trading_cycle(tg_id, message):
task = asyncio.create_task(trading_cycle(tg_id, message))
active_start_tasks[tg_id] = task
def stop_trading_cycle(tg_id):
task = active_start_tasks.pop(tg_id, None)
if task:
task.cancel()
def start_close_trade_task(tg_id, message, symbol, delay_sec):
task = asyncio.create_task(close_trade_after_delay(tg_id, message, symbol, delay_sec))
active_close_tasks[tg_id] = task
def stop_close_trade_task(tg_id):
task = active_close_tasks.pop(tg_id, None)
if task:
task.cancel()