adjusted percentages of TP and SL

This commit is contained in:
algizn97
2025-10-29 20:55:51 +05:00
parent 7e4c936ef5
commit a8119d2811
4 changed files with 15 additions and 15 deletions

View File

@@ -179,3 +179,9 @@ async def calculate_total_budget(
total += r_quantity
return total
async def truncate_float(f, decimals=4):
factor = 10 ** decimals
return int(f * factor) / factor

View File

@@ -121,7 +121,7 @@ async def set_symbol(message: Message, state: FSMContext) -> None:
)
await rq.set_leverage(tg_id=message.from_user.id, leverage=str(max_leverage))
risk_percent = 100 / safe_float(max_leverage)
risk_percent = 10 / safe_float(max_leverage)
await rq.set_stop_loss_percent(
tg_id=message.from_user.id, stop_loss_percent=risk_percent)
await rq.set_take_profit_percent(

View File

@@ -660,7 +660,7 @@ async def set_leverage_handler(message: Message, state: FSMContext) -> None:
text=f"Кредитное плечо успешно установлено на {leverage_float}",
reply_markup=kbi.back_to_additional_settings,
)
risk_percent = 100 / safe_float(leverage_float)
risk_percent = 10 / safe_float(leverage_float)
await rq.set_stop_loss_percent(
tg_id=message.from_user.id, stop_loss_percent=risk_percent)
await rq.set_take_profit_percent(

View File

@@ -39,21 +39,15 @@ async def stop_all_trading(callback_query: CallbackQuery, state: FSMContext):
await rq.set_stop_timer(tg_id=callback_query.from_user.id, timer_end=0)
await asyncio.sleep(timer_end * 60)
user_auto_trading = await rq.get_user_auto_trading(
tg_id=callback_query.from_user.id, symbol=symbol
await rq.set_auto_trading(
tg_id=callback_query.from_user.id,
symbol=symbol,
auto_trading=False,
)
await close_position_by_symbol(
tg_id=callback_query.from_user.id, symbol=symbol)
await callback_query.message.edit_text(text=f"Торговля для {symbol} остановлена", reply_markup=kbi.profile_bybit)
if user_auto_trading and user_auto_trading.auto_trading:
await rq.set_auto_trading(
tg_id=callback_query.from_user.id,
symbol=symbol,
auto_trading=False,
)
await close_position_by_symbol(
tg_id=callback_query.from_user.id, symbol=symbol)
await callback_query.message.edit_text(text=f"Торговля для {symbol} остановлена", reply_markup=kbi.profile_bybit)
else:
await callback_query.message.edit_text(text=f"Нет активной торговли для {symbol}", reply_markup=kbi.profile_bybit)
task = asyncio.create_task(delay_start())
await add_stop_task(user_id=callback_query.from_user.id, task=task)