Fixed take profit calculation. Added a position check for the current pair when trying to change the margin.
This commit is contained in:
@@ -41,11 +41,26 @@ class TelegramMessageHandler:
|
||||
if order_status == "Filled" or order_status not in status_map:
|
||||
return None
|
||||
|
||||
user_auto_trading = await rq.get_user_auto_trading(
|
||||
tg_id=tg_id, symbol=symbol
|
||||
)
|
||||
auto_trading = (
|
||||
user_auto_trading.auto_trading if user_auto_trading else False
|
||||
)
|
||||
user_deals_data = await rq.get_user_deal_by_symbol(
|
||||
tg_id=tg_id, symbol=symbol
|
||||
)
|
||||
|
||||
text = (
|
||||
f"Торговая пара: {symbol}\n"
|
||||
f"Количество: {qty}\n"
|
||||
f"Движение: {side_rus}\n"
|
||||
)
|
||||
|
||||
if user_deals_data is not None and auto_trading:
|
||||
text += f"Текущая ставка: {user_deals_data.order_quantity}\n"
|
||||
else:
|
||||
text += f"Количество: {qty}\n"
|
||||
|
||||
if price and price != "0":
|
||||
text += f"Цена: {price}\n"
|
||||
if take_profit and take_profit != "Нет данных":
|
||||
@@ -185,7 +200,7 @@ class TelegramMessageHandler:
|
||||
"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": "❗️ Превышен максимальный лимит ставки",
|
||||
}
|
||||
error_text = errors.get(
|
||||
res, "❗️ Не удалось открыть новую сделку"
|
||||
|
Reference in New Issue
Block a user