The stop trading button has been added, and the switch mode has been fixed
This commit is contained in:
@@ -4,9 +4,6 @@ from aiogram import Router
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.types import CallbackQuery
|
||||
|
||||
import database.request as rq
|
||||
from app.bybit.close_positions import cancel_order, close_position
|
||||
from app.helper_functions import safe_float
|
||||
from logger_helper.logger_helper import LOGGING_CONFIG
|
||||
|
||||
logging.config.dictConfig(LOGGING_CONFIG)
|
||||
@@ -28,31 +25,6 @@ async def close_position_handler(
|
||||
:return: None
|
||||
"""
|
||||
try:
|
||||
data = callback_query.data
|
||||
parts = data.split("_")
|
||||
symbol = parts[2]
|
||||
side = parts[3]
|
||||
position_idx = int(parts[4])
|
||||
qty = safe_float(parts[5])
|
||||
await rq.set_auto_trading(
|
||||
tg_id=callback_query.from_user.id,
|
||||
symbol=symbol,
|
||||
auto_trading=False,
|
||||
side=side,
|
||||
)
|
||||
res = await close_position(
|
||||
tg_id=callback_query.from_user.id,
|
||||
symbol=symbol,
|
||||
side=side,
|
||||
position_idx=position_idx,
|
||||
qty=qty,
|
||||
)
|
||||
|
||||
if not res:
|
||||
await callback_query.answer(text="Произошла ошибка при закрытии позиции.")
|
||||
return
|
||||
|
||||
await callback_query.answer(text="Позиция успешно закрыта.")
|
||||
logger.debug(
|
||||
"Command close_position processed successfully for user: %s",
|
||||
callback_query.from_user.id,
|
||||
@@ -81,19 +53,6 @@ async def cancel_order_handler(
|
||||
:return: None
|
||||
"""
|
||||
try:
|
||||
data = callback_query.data
|
||||
parts = data.split("_")
|
||||
symbol = parts[2]
|
||||
order_id = parts[3]
|
||||
res = await cancel_order(
|
||||
tg_id=callback_query.from_user.id, symbol=symbol, order_id=order_id
|
||||
)
|
||||
|
||||
if not res:
|
||||
await callback_query.answer(text="Произошла ошибка при закрытии ордера.")
|
||||
return
|
||||
|
||||
await callback_query.answer(text="Ордер успешно закрыт.")
|
||||
logger.debug(
|
||||
"Command close_order processed successfully for user: %s",
|
||||
callback_query.from_user.id,
|
||||
|
Reference in New Issue
Block a user