forked from kodorvan/stcs
29 lines
827 B
Python
29 lines
827 B
Python
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
|