1
0
forked from kodorvan/stcs

fix app/telegram/handlers/handlers.py, fix app/telegram/functions/functions.py || change two buttons "Начать торговлю" || fix text registration message, fix text profile || delete app/services/Bybit/config.py || delete comments

This commit is contained in:
Kirill Strelnikov
2025-07-21 16:55:30 +07:00
parent fb0c14aba1
commit 242be34a97
9 changed files with 34 additions and 145 deletions

View File

@@ -71,7 +71,7 @@ async def contract_long(tg_id, message, margin_mode):
setMarginMode=margin_mode # margin_type
)
martingale_factor = float(data_main_stgs['martingale_factor']) # Исправлено: было maximal_quantity
martingale_factor = float(data_main_stgs['martingale_factor'])
max_martingale_steps = int(data_main_stgs['maximal_quantity'])
starting_quantity = float(data_main_stgs['starting_quantity'])
max_risk_percent = float(data_risk_management_stgs['max_risk_deal'])
@@ -172,23 +172,7 @@ async def contract_long(tg_id, message, margin_mode):
orderLinkId=f"deal_{SYMBOL}_{time.time()}"
)
await info_access_open_deal(message, SYMBOL, data_main_stgs['trading_mode'], margin_mode, data_main_stgs['size_leverage'], next_quantity)
print(f'''
=====================
===================
===================
===================
=================
{r}
===============
===============
=============
===============
==============
''')
await info_access_open_deal(message, SYMBOL, data_main_stgs['trading_mode'], margin_mode, data_main_stgs['size_leverage'], next_quantity)
except exceptions.InvalidRequestError as e:
await message.answer('Недостаточно баланса')
@@ -225,7 +209,7 @@ async def contract_short(tg_id, message, margin_mode):
setMarginMode=margin_mode # margin_type
)
martingale_factor = float(data_main_stgs['martingale_factor']) # Исправлено: было maximal_quantity
martingale_factor = float(data_main_stgs['martingale_factor'])
max_martingale_steps = int(data_main_stgs['maximal_quantity'])
starting_quantity = float(data_main_stgs['starting_quantity'])
max_risk_percent = float(data_risk_management_stgs['max_risk_deal'])
@@ -251,47 +235,17 @@ async def contract_short(tg_id, message, margin_mode):
realised_pnl = float(position['unrealisedPnl'])
if realised_pnl > 0:
print(f'''
=====================
=====Сделка=========
===уСПЕШНЕАЯ================
===================
=================
{realised_pnl}
===============
===============
=============
===============
==============
''')
if realised_pnl > 0: # Прибыльная сделка
starting_quantity = next_quantity
current_martingale_step = 0
elif not realised_pnl:
next_quantity = starting_quantity
current_martingale_step += 1
else:
else: # Убыточная сделка
current_martingale_step += 1
next_quantity = last_quantity * martingale_factor
starting_quantity = next_quantity
print(f'''
======СДЕЛКА===============
=====УБЫТОЧНАЯ==============
===================
===================
=================
{realised_pnl}
===============
===============
=============
===============
==============
''')
except Exception as e:
print("Не получены позиции")
next_quantity = starting_quantity
@@ -324,23 +278,7 @@ async def contract_short(tg_id, message, margin_mode):
orderLinkId=f"deal_{SYMBOL}_{time.time()}"
)
await info_access_open_deal(message, SYMBOL, data_main_stgs['trading_mode'], margin_mode, data_main_stgs['size_leverage'], next_quantity)
print(f'''
=====================
===================
===================
===================
=================
{r}
===============
===============
=============
===============
==============
''')
await info_access_open_deal(message, SYMBOL, data_main_stgs['trading_mode'], margin_mode, data_main_stgs['size_leverage'], next_quantity)
except exceptions.InvalidRequestError as e:
await message.answer('Недостаточно баланса')

View File

@@ -16,23 +16,7 @@ async def get_balance(tg_id, message):
try:
balance = client.get_wallet_balance(accountType='UNIFIED', coin='USDT')['result']['list'][0]['coin'][0]['walletBalance']
print(f'''
=====================
=====BALANCE=========
======USDT=============
===================
=================
{balance}
===============
===============
=============
===============
==============
''')
return balance
except Exception as e:
await message.answer('Баланс не был получен')
await message.answer('Баланс не был получен, подключите платформу')
return 0

View File

@@ -18,20 +18,4 @@ async def get_min_qty(tg_id, message):
price = await price_s.get_price(tg_id, message)
min_qty = int(5 / price * 1.1)
print(f'''
=====================
=====MIN=========
=====QTY==============
===================
=================
{min_qty}
===============
===============
=============
===============
==============
''')
return min_qty

View File

@@ -94,10 +94,8 @@ async def make_deal_bybit (callback: CallbackQuery):
else:
match trade_mode:
case 'Long':
print('====================================LONG=========================================')
await Futures.contract_long(callback.from_user.id, callback.message, margin_mode)
case 'Short':
print('====================================SHORT=========================================')
await Futures.contract_short(callback.from_user.id, callback.message, margin_mode)
case 'Switch':
await callback.message.edit_text('Режим Switch пока недоступен')

View File

@@ -18,22 +18,6 @@ async def get_price(tg_id, message):
try:
price = float(client.get_tickers(category='linear', symbol=SYMBOL).get('result').get('list')[0].get('ask1Price'))
print(f'''
=====================
=====PRICE=========
===================
===================
=================
{price}
===============
===============
=============
===============
==============
''')
return price
except exceptions.InvalidRequestError as e:
await message.answer('Неверно указана торговая пара')