2
0
forked from kodorvan/stcs

When adjusting the leverage, the SL changes according to the criteria. In place of the position mode, there is now a trading mode. All unnecessary functions are also removed.

This commit is contained in:
algizn97
2025-10-10 13:59:24 +05:00
parent 9f9a79bf81
commit 1a1a5a727f

View File

@@ -142,7 +142,9 @@ async def switch_side_start(callback_query: CallbackQuery, state: FSMContext) ->
)
@router_additional_settings.callback_query(lambda c: c.data == "switch_direction" or c.data == "switch_opposite")
@router_additional_settings.callback_query(
lambda c: c.data == "switch_direction" or c.data == "switch_opposite"
)
async def switch_side_handler(callback_query: CallbackQuery, state: FSMContext) -> None:
"""
Handles callback queries related to switch side selection.
@@ -214,7 +216,7 @@ async def settings_for_margin_type(
await callback_query.message.edit_text(
text="Выберите тип маржи:\n\n"
"Примечание: Если у вас есть открытые позиции, то маржа примениться ко всем позициям",
reply_markup=kbi.margin_type
reply_markup=kbi.margin_type,
)
logger.debug(
"Command margin_type processed successfully for user: %s",
@@ -553,7 +555,8 @@ async def set_leverage_handler(message: Message, state: FSMContext) -> None:
)
risk_percent = 100 / safe_float(leverage_float)
await rq.set_stop_loss_percent(
tg_id=message.from_user.id, stop_loss_percent=risk_percent)
tg_id=message.from_user.id, stop_loss_percent=risk_percent
)
logger.info(
"User %s set leverage: %s", message.from_user.id, leverage_float
)
@@ -767,9 +770,14 @@ async def set_martingale_factor(message: Message, state: FSMContext) -> None:
martingale_factor_value_float = safe_float(martingale_factor_value)
if martingale_factor_value_float < 0.1 or martingale_factor_value_float > 10:
await message.answer(text="Ошибка: коэффициент мартингейла должен быть в диапазоне от 0.1 до 10")
logger.debug("User %s input invalid (not in range 0.1 to 10): %s", message.from_user.id,
martingale_factor_value_float)
await message.answer(
text="Ошибка: коэффициент мартингейла должен быть в диапазоне от 0.1 до 10"
)
logger.debug(
"User %s input invalid (not in range 0.1 to 10): %s",
message.from_user.id,
martingale_factor_value_float,
)
return
req = await rq.set_martingale_factor(
@@ -878,7 +886,10 @@ async def set_max_bets_in_series(message: Message, state: FSMContext) -> None:
)
return
if safe_float(max_bets_in_series_value) < 1 or safe_float(max_bets_in_series_value) > 100:
if (
safe_float(max_bets_in_series_value) < 1
or safe_float(max_bets_in_series_value) > 100
):
await message.answer(
"Ошибка: число должно быть в диапазоне от 1 до 100.",
reply_markup=kbi.back_to_additional_settings,