Fixed
This commit is contained in:
@@ -23,42 +23,12 @@ async def reg_new_user_default_condition_settings(id):
|
||||
|
||||
|
||||
async def main_settings_message(id, message):
|
||||
|
||||
tg_id = id
|
||||
trigger = await rq.get_for_registration_trigger(tg_id)
|
||||
text = f""" <b>Условия запуска</b>
|
||||
|
||||
<b>- Режим торговли:</b> {trigger}
|
||||
<b>- Таймер: </b> установить таймер / удалить таймер
|
||||
"""
|
||||
await message.answer(text=text, parse_mode='html', reply_markup=inline_markup.condition_settings_markup)
|
||||
|
||||
|
||||
async def trigger_message(id, message, state: FSMContext):
|
||||
await state.set_state(condition_settings.trigger)
|
||||
text = '''
|
||||
<b>- Автоматический:</b> торговля будет происходить в рамках серии ставок.
|
||||
<b>- Ручной:</b> торговля будет происходить только в ручном режиме.
|
||||
<em>- Выберите тип триггера:</em>'''
|
||||
|
||||
await message.answer(text=text, parse_mode='html', reply_markup=inline_markup.trigger_markup)
|
||||
|
||||
|
||||
@condition_settings_router.callback_query(F.data == "clb_trigger_manual")
|
||||
async def trigger_manual_callback(callback: CallbackQuery, state: FSMContext):
|
||||
await state.set_state(condition_settings.trigger)
|
||||
await rq.update_trigger(tg_id=callback.from_user.id, trigger="Ручной")
|
||||
await main_settings_message(callback.from_user.id, callback.message)
|
||||
await callback.answer()
|
||||
|
||||
|
||||
@condition_settings_router.callback_query(F.data == "clb_trigger_auto")
|
||||
async def trigger_manual_callback(callback: CallbackQuery, state: FSMContext):
|
||||
await state.set_state(condition_settings.trigger)
|
||||
await rq.update_trigger(tg_id=callback.from_user.id, trigger="Автоматический")
|
||||
await main_settings_message(callback.from_user.id, callback.message)
|
||||
await callback.answer()
|
||||
|
||||
async def timer_message(id, message: Message, state: FSMContext):
|
||||
await state.set_state(condition_settings.timer)
|
||||
|
||||
@@ -140,4 +110,4 @@ async def ai_analytics_message(message, state):
|
||||
|
||||
Описание... '''
|
||||
|
||||
await message.answer(text=text, parse_mode='html', reply_markup=inline_markup.buttons_yes_no_markup)
|
||||
await message.answer(text=text, parse_mode='html', reply_markup=inline_markup.buttons_yes_no_markup)
|
||||
|
@@ -6,7 +6,6 @@ from pybit.unified_trading import HTTP
|
||||
import app.telegram.database.requests as rq
|
||||
from aiogram.types import Message, CallbackQuery
|
||||
|
||||
from app.services.Bybit.functions.price_symbol import get_price
|
||||
from app.services.Bybit.functions.Futures import safe_float, calculate_total_budget, get_bybit_client
|
||||
from app.states.States import update_main_settings
|
||||
from logger_helper.logger_helper import LOGGING_CONFIG
|
||||
@@ -40,9 +39,6 @@ async def main_settings_message(id, message):
|
||||
starting_quantity = safe_float((data_main_stgs or {}).get('starting_quantity'))
|
||||
martingale_factor = safe_float((data_main_stgs or {}).get('martingale_factor'))
|
||||
fee_info = client.get_fee_rates(category='linear', symbol=symbol)
|
||||
leverage = safe_float((data_main_stgs or {}).get('size_leverage'))
|
||||
price = await get_price(tg_id, symbol=symbol)
|
||||
entry_price = safe_float(price)
|
||||
|
||||
if commission_fee == "Да":
|
||||
commission_fee_percent = safe_float(fee_info['result']['list'][0]['takerFeeRate'])
|
||||
@@ -54,8 +50,6 @@ async def main_settings_message(id, message):
|
||||
martingale_factor=martingale_factor,
|
||||
max_steps=max_martingale_steps,
|
||||
commission_fee_percent=commission_fee_percent,
|
||||
leverage=leverage,
|
||||
current_price=entry_price,
|
||||
)
|
||||
|
||||
await message.answer(f"""<b>Основные настройки</b>
|
||||
@@ -267,26 +261,7 @@ async def state_margin_type(callback: CallbackQuery, state):
|
||||
callback_data = callback.data
|
||||
if callback_data in ['margin_type_isolated', 'margin_type_cross']:
|
||||
tg_id = callback.from_user.id
|
||||
api_key = await rq.get_bybit_api_key(tg_id)
|
||||
secret_key = await rq.get_bybit_secret_key(tg_id)
|
||||
data_settings = await rq.get_user_main_settings(tg_id)
|
||||
symbol = await rq.get_symbol(tg_id)
|
||||
client = HTTP(api_key=api_key, api_secret=secret_key)
|
||||
try:
|
||||
active_positions = client.get_positions(category='linear', settleCoin="USDT")
|
||||
|
||||
positions = active_positions.get('result', {}).get('list', [])
|
||||
except Exception as e:
|
||||
logger.error("Ошибка при получении активных позиций: %s", e)
|
||||
positions = []
|
||||
|
||||
for pos in positions:
|
||||
size = pos.get('size')
|
||||
if float(size) > 0:
|
||||
await callback.answer(
|
||||
"⚠️ Маржинальный режим нельзя менять при открытой позиции"
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
match callback.data:
|
||||
@@ -333,6 +308,7 @@ async def state_starting_quantity(message: Message, state):
|
||||
await message.answer(f"✅ Изменено: {data_settings['starting_quantity']} → {data['starting_quantity']}")
|
||||
|
||||
await rq.update_starting_quantity(message.from_user.id, data['starting_quantity'])
|
||||
await rq.update_base_quantity(tg_id=message.from_user.id, num=data['starting_quantity'])
|
||||
await main_settings_message(message.from_user.id, message)
|
||||
|
||||
await state.clear()
|
||||
|
Reference in New Issue
Block a user