forked from kodorvan/stcs
The entire database has been changed to PostgresSQL. The entire code has been updated.
This commit is contained in:
28
app/bybit/get_functions/get_balance.py
Normal file
28
app/bybit/get_functions/get_balance.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import logging.config
|
||||
|
||||
from app.bybit import get_bybit_client
|
||||
from app.bybit.logger_bybit.logger_bybit import LOGGING_CONFIG
|
||||
|
||||
logging.config.dictConfig(LOGGING_CONFIG)
|
||||
logger = logging.getLogger("get_balance")
|
||||
|
||||
|
||||
async def get_balance(tg_id: int) -> bool | dict:
|
||||
"""
|
||||
Get balance bybit
|
||||
"""
|
||||
client = await get_bybit_client(tg_id=tg_id)
|
||||
|
||||
try:
|
||||
response = client.get_wallet_balance(accountType="UNIFIED")
|
||||
if response["retCode"] == 0:
|
||||
info = response["result"]["list"][0]
|
||||
return info
|
||||
else:
|
||||
logger.error(
|
||||
"Error getting balance for user %s: %s", tg_id, response.get("retMsg")
|
||||
)
|
||||
return False
|
||||
except Exception as e:
|
||||
logger.error("Error connecting to Bybit for user %s: %s", tg_id, e)
|
||||
return False
|
Reference in New Issue
Block a user