forked from kodorvan/stcs
version 1 STCS
This commit is contained in:
38
app/services/Bybit/functions/balance.py
Normal file
38
app/services/Bybit/functions/balance.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import app.telegram.database.requests as rq
|
||||
|
||||
from pybit.unified_trading import HTTP
|
||||
|
||||
client = HTTP()
|
||||
|
||||
async def get_balance(tg_id, message):
|
||||
api_key = await rq.get_bybit_api_key(tg_id)
|
||||
secret_key = await rq.get_bybit_secret_key(tg_id)
|
||||
|
||||
client = HTTP(
|
||||
api_key=api_key,
|
||||
api_secret=secret_key
|
||||
)
|
||||
|
||||
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('Баланс не был получен')
|
||||
return 0
|
Reference in New Issue
Block a user