initial balance on dash

This commit is contained in:
Dobromir Popov
2025-05-27 13:53:12 +03:00
parent 4567912186
commit ae62d893bc
4 changed files with 307 additions and 26 deletions

View File

@ -401,4 +401,47 @@ class TradingExecutor:
"""Reset daily statistics (call at start of new day)"""
self.daily_trades = 0
self.daily_loss = 0.0
logger.info("Daily trading statistics reset")
logger.info("Daily trading statistics reset")
def get_account_balance(self) -> Dict[str, Dict[str, float]]:
"""Get account balance information from MEXC
Returns:
Dict with asset balances in format:
{
'USDT': {'free': 100.0, 'locked': 0.0},
'ETH': {'free': 0.5, 'locked': 0.0},
...
}
"""
try:
if not self.exchange:
logger.error("Exchange interface not available")
return {}
# Get account info from MEXC
account_info = self.exchange.get_account_info()
if not account_info:
logger.error("Failed to get account info from MEXC")
return {}
balances = {}
for balance in account_info.get('balances', []):
asset = balance.get('asset', '')
free = float(balance.get('free', 0))
locked = float(balance.get('locked', 0))
# Only include assets with non-zero balance
if free > 0 or locked > 0:
balances[asset] = {
'free': free,
'locked': locked,
'total': free + locked
}
logger.info(f"Retrieved balances for {len(balances)} assets")
return balances
except Exception as e:
logger.error(f"Error getting account balance: {e}")
return {}