Fixed
This commit is contained in:
@@ -9,6 +9,7 @@ import app.telegram.keyboards.inline as kbi
|
||||
import database.request as rq
|
||||
from app.bybit.get_functions.get_positions import get_active_positions_by_symbol
|
||||
from app.bybit.open_positions import start_trading_cycle
|
||||
from app.helper_functions import safe_float
|
||||
from logger_helper.logger_helper import LOGGING_CONFIG
|
||||
|
||||
logging.config.dictConfig(LOGGING_CONFIG)
|
||||
@@ -41,14 +42,14 @@ async def start_trading(callback_query: CallbackQuery, state: FSMContext) -> Non
|
||||
size = deals.get("size") or 0
|
||||
position_idx = deals.get("positionIdx")
|
||||
|
||||
if position_idx != 0 and int(size) > 0 and trade_mode == "Merged_Single":
|
||||
if position_idx != 0 and safe_float(size) > 0 and trade_mode == "Merged_Single":
|
||||
await callback_query.answer(
|
||||
text="У вас есть активная позиция в режиме хеджирования. "
|
||||
"Открытие сделки в одностороннем режиме невозможно.",
|
||||
)
|
||||
return
|
||||
|
||||
if position_idx == 0 and int(size) > 0 and trade_mode == "Both_Sides":
|
||||
if position_idx == 0 and safe_float(size) > 0 and trade_mode == "Both_Sides":
|
||||
await callback_query.answer(
|
||||
text="У вас есть активная позиция в одностороннем режиме. "
|
||||
"Открытие сделки в режиме хеджирования невозможно.",
|
||||
@@ -108,7 +109,7 @@ async def start_trading_long(callback_query: CallbackQuery, state: FSMContext) -
|
||||
size = deals.get("size") or 0
|
||||
position_idx = deals.get("positionIdx")
|
||||
|
||||
if position_idx == 0 and int(size) > 0:
|
||||
if position_idx == 0 and safe_float(size) > 0:
|
||||
await callback_query.answer(
|
||||
text="Торговля уже запущена в одностороннем режиме для данного инструмента"
|
||||
)
|
||||
@@ -251,13 +252,13 @@ async def start_switch(callback_query: CallbackQuery, state: FSMContext) -> None
|
||||
size = deals.get("size") or 0
|
||||
position_idx = deals.get("positionIdx")
|
||||
|
||||
if position_idx == 1 and int(size) > 0 and side == "Buy":
|
||||
if position_idx == 1 and safe_float(size) > 0 and side == "Buy":
|
||||
await callback_query.answer(
|
||||
text="Торговля уже запущена в режиме хеджирования на покупку для данного инструмента"
|
||||
)
|
||||
return
|
||||
|
||||
if position_idx == 2 and int(size) > 0 and side == "Sell":
|
||||
if position_idx == 2 and safe_float(size) > 0 and side == "Sell":
|
||||
await callback_query.answer(
|
||||
text="Торговля уже запущена в режиме хеджирования на продажу для данного инструмента"
|
||||
)
|
||||
|
Reference in New Issue
Block a user