|
@@ -533,6 +533,9 @@ Tap any button below for instant access to bot functions:
|
|
|
if balance:
|
|
|
balance_text = "💰 <b>Account Balance</b>\n\n"
|
|
|
|
|
|
+ # Debug: Show raw balance structure (can be removed after debugging)
|
|
|
+ logger.debug(f"Raw balance data: {balance}")
|
|
|
+
|
|
|
# CCXT balance structure includes 'free', 'used', and 'total'
|
|
|
total_balance = balance.get('total', {})
|
|
|
free_balance = balance.get('free', {})
|
|
@@ -557,10 +560,14 @@ Tap any button below for instant access to bot functions:
|
|
|
|
|
|
balance_text += "\n"
|
|
|
|
|
|
- # Calculate totals for USDC (main trading currency)
|
|
|
+ # Calculate totals (convert all to USDC equivalent for summary)
|
|
|
if asset == 'USDC':
|
|
|
total_value += float(amount)
|
|
|
available_value += free_amount
|
|
|
+ else:
|
|
|
+ # For non-USDC assets, add to totals (assuming 1:1 for now, could be enhanced with price conversion)
|
|
|
+ total_value += float(amount)
|
|
|
+ available_value += free_amount
|
|
|
|
|
|
# Summary section
|
|
|
balance_text += f"💼 <b>Portfolio Summary:</b>\n"
|
|
@@ -573,10 +580,12 @@ Tap any button below for instant access to bot functions:
|
|
|
# Add P&L summary
|
|
|
basic_stats = self.stats.get_basic_stats()
|
|
|
if basic_stats['initial_balance'] > 0:
|
|
|
- pnl = total_value - basic_stats['initial_balance']
|
|
|
+ # Use USDC balance for P&L calculation
|
|
|
+ usdc_total = float(total_balance.get('USDC', 0))
|
|
|
+ pnl = usdc_total - basic_stats['initial_balance']
|
|
|
pnl_percent = (pnl / basic_stats['initial_balance']) * 100
|
|
|
|
|
|
- balance_text += f"\n📊 <b>Performance:</b>\n"
|
|
|
+ balance_text += f"\n📊 <b>Performance (USDC):</b>\n"
|
|
|
balance_text += f" 💵 P&L: ${pnl:,.2f} ({pnl_percent:+.2f}%)\n"
|
|
|
balance_text += f" 📈 Initial: ${basic_stats['initial_balance']:,.2f}"
|
|
|
else:
|
|
@@ -639,7 +648,7 @@ Tap any button below for instant access to bot functions:
|
|
|
else:
|
|
|
positions_text += "📭 <b>No open positions currently</b>\n\n"
|
|
|
positions_text += "🚀 Ready to start trading!\n"
|
|
|
- positions_text += "Use /buy or /sell commands to open positions."
|
|
|
+ positions_text += "Use /long or /short commands to open positions."
|
|
|
else:
|
|
|
# Actual API error
|
|
|
positions_text = "❌ <b>Could not fetch positions data</b>\n\n"
|
|
@@ -661,6 +670,10 @@ Tap any button below for instant access to bot functions:
|
|
|
|
|
|
orders = self.client.get_open_orders()
|
|
|
|
|
|
+ # Debug: Log what we got from orders
|
|
|
+ logger.debug(f"Raw orders data: {orders}")
|
|
|
+ logger.debug(f"Orders type: {type(orders)}, Length: {len(orders) if orders else 'None'}")
|
|
|
+
|
|
|
if orders is not None: # Successfully fetched (could be empty list)
|
|
|
if token_filter:
|
|
|
orders_text = f"📋 <b>Open Orders - {token_filter}</b>\n\n"
|