This commit is contained in:
algizn97
2025-08-21 16:10:01 +05:00
parent f8cedf4cb4
commit eaf8458835
3 changed files with 47 additions and 7 deletions

View File

@@ -280,14 +280,17 @@ async def open_market_order(tg_id, message, api_key, secret_key):
await contract_long(tg_id, message, margin_mode)
elif trading_mode == 'Short':
await contract_short(tg_id, message, margin_mode)
else:
await message.answer("Неизвестный режим торговли: выберите Long или Short.")
elif trading_mode == 'Smart':
await message.answer("Режим Smart пока недоступен")
elif trading_mode == 'Switch':
await message.answer("Режим Switch пока недоступен")
async def open_limit_order(tg_id, message, price, api_key, secret_key):
data_main_stgs = await rq.get_user_main_settings(tg_id)
trading_mode = data_main_stgs['trading_mode']
margin_mode = data_main_stgs.get('margin_type')
order_type = await rq.get_entry_order_type(tg_id)
client = HTTP(
@@ -297,7 +300,7 @@ async def open_limit_order(tg_id, message, price, api_key, secret_key):
symbol = await rq.get_symbol(tg_id)
qty = float(data_main_stgs['starting_quantity'])
side = 'Buy' if trading_mode == 'Long' else 'Sell'
side = 'Buy' if trading_mode == 'Long' else 'Short'
try:
@@ -313,6 +316,8 @@ async def open_limit_order(tg_id, message, price, api_key, secret_key):
)
if response.get('retCode') == 0:
await message.answer(f"Limit ордер открыт: {side} {qty} {symbol} по цене {price}")
await rq.update_user_trades(tg_id, symbol=symbol, side=order_type)
else:
await message.answer(f"Ошибка открытия ордера: {response.get('retMsg')}")
except Exception as e: