initial balance on dash
This commit is contained in:
@ -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 {}
|
Reference in New Issue
Block a user