more live trades fix
This commit is contained in:
@ -230,15 +230,25 @@ class TradingExecutor:
|
||||
required_capital = self._calculate_position_size(confidence, current_price)
|
||||
|
||||
# Get available balance for the quote asset
|
||||
available_balance = self.exchange.get_balance(quote_asset)
|
||||
|
||||
# If USDC balance is insufficient, check USDT as fallback (for MEXC compatibility)
|
||||
if available_balance < required_capital and quote_asset == 'USDC':
|
||||
# For MEXC, prioritize USDT over USDC since most accounts have USDT
|
||||
if quote_asset == 'USDC':
|
||||
# Check USDT first (most common balance)
|
||||
usdt_balance = self.exchange.get_balance('USDT')
|
||||
usdc_balance = self.exchange.get_balance('USDC')
|
||||
|
||||
if usdt_balance >= required_capital:
|
||||
available_balance = usdt_balance
|
||||
quote_asset = 'USDT' # Use USDT instead
|
||||
logger.info(f"BALANCE CHECK: Using USDT fallback balance for {symbol}")
|
||||
quote_asset = 'USDT' # Use USDT for trading
|
||||
logger.info(f"BALANCE CHECK: Using USDT balance for {symbol} (preferred)")
|
||||
elif usdc_balance >= required_capital:
|
||||
available_balance = usdc_balance
|
||||
logger.info(f"BALANCE CHECK: Using USDC balance for {symbol}")
|
||||
else:
|
||||
# Use the larger balance for reporting
|
||||
available_balance = max(usdt_balance, usdc_balance)
|
||||
quote_asset = 'USDT' if usdt_balance > usdc_balance else 'USDC'
|
||||
else:
|
||||
available_balance = self.exchange.get_balance(quote_asset)
|
||||
|
||||
logger.info(f"BALANCE CHECK: Symbol: {symbol}, Action: {action}, Required: ${required_capital:.2f} {quote_asset}, Available: ${available_balance:.2f} {quote_asset}")
|
||||
|
||||
|
Reference in New Issue
Block a user