This commit is contained in:
algizn97
2025-10-04 11:03:49 +05:00
parent 220c45d54c
commit 01fe339d56
5 changed files with 82 additions and 39 deletions

View File

@@ -123,7 +123,7 @@ async def start_trading_cycle(
"Order does not meet minimum order value",
"position idx not match position mode",
"Qty invalid",
"The number of contracts exceeds maximum limit allowed"
"The number of contracts exceeds maximum limit allowed",
}
else None
)
@@ -241,7 +241,7 @@ async def trading_cycle(
"Risk is too high for this trade",
"ab not enough for new order",
"InvalidRequestError",
"The number of contracts exceeds maximum limit allowed"
"The number of contracts exceeds maximum limit allowed",
}
else None
)

View File

@@ -163,9 +163,7 @@ class TelegramMessageHandler:
auto_trading = (
user_auto_trading.auto_trading if user_auto_trading else False
)
user_symbols = (
user_auto_trading.symbol if user_auto_trading else None
)
user_symbols = user_auto_trading.symbol if user_auto_trading else None
if (
auto_trading
@@ -181,10 +179,16 @@ class TelegramMessageHandler:
r_side = "Sell"
else:
r_side = "Buy"
await rq.set_auto_trading(tg_id=tg_id, symbol=symbol, auto_trading=False, side=r_side)
user_deals_data = await rq.get_user_deal_by_symbol(tg_id=tg_id, symbol=symbol)
await rq.set_auto_trading(
tg_id=tg_id, symbol=symbol, auto_trading=False, side=r_side
)
user_deals_data = await rq.get_user_deal_by_symbol(
tg_id=tg_id, symbol=symbol
)
if user_deals_data and user_deals_data.switch_side_mode:
await rq.set_auto_trading(tg_id=tg_id, symbol=symbol, auto_trading=False, side=side)
await rq.set_auto_trading(
tg_id=tg_id, symbol=symbol, auto_trading=False, side=side
)
else:
open_order_text = "\n❗️ Сделка закрылась в минус, открываю новую сделку с увеличенной ставкой.\n"
await self.telegram_bot.send_message(
@@ -214,10 +218,15 @@ class TelegramMessageHandler:
await rq.set_auto_trading(
tg_id=tg_id, symbol=symbol, auto_trading=False, side=r_side
)
user_deals_data = await rq.get_user_deal_by_symbol(tg_id=tg_id, symbol=symbol)
user_deals_data = await rq.get_user_deal_by_symbol(
tg_id=tg_id, symbol=symbol
)
if user_deals_data and user_deals_data.switch_side_mode:
await rq.set_auto_trading(
tg_id=tg_id, symbol=symbol, auto_trading=False, side=side
tg_id=tg_id,
symbol=symbol,
auto_trading=False,
side=side,
)
await self.telegram_bot.send_message(
chat_id=tg_id,