#!/usr/bin/env python3 """ Live Status Reporter — Always fresh data from Binance API + Bot State No caching, no stale data. Real-time updates. """ import os import json import time from datetime import datetime from binance.client import Client from dotenv import load_dotenv os.chdir('/home/marc/bot-deploy') load_dotenv() client = Client(os.getenv('BINANCE_API_KEY_LIVE'), os.getenv('BINANCE_API_SECRET_LIVE')) # Bot's tracked symbols TRACKED_ASSETS = {'USDT', 'BTC', 'ETH', 'BNB', 'XRP', 'SOL'} def get_live_data(): """Fetch ALWAYS FRESH data from Binance""" try: print(f'\nšŸ“Š LIVE DATA @ {datetime.now().strftime("%H:%M:%S CET")}') print('='*70) # 1. Account balance (FRESH from API) acc = client.get_account() balances = {b['asset']: float(b['free']) + float(b['locked']) for b in acc['balances'] if float(b['free']) + float(b['locked']) > 0} # Filter to ONLY tracked assets tracked_balances = {asset: qty for asset, qty in balances.items() if asset in TRACKED_ASSETS and qty > 0.0001} usdt = tracked_balances.get('USDT', 0) usdt_free = sum(float(b['free']) for b in acc['balances'] if b['asset'] == 'USDT') usdt_locked = sum(float(b['locked']) for b in acc['balances'] if b['asset'] == 'USDT') print(f'USDT Total: ${usdt:.2f} (Free: ${usdt_free:.2f} | Locked: ${usdt_locked:.2f})') # 2. Holdings (ONLY tracked coins) holdings = {k: v for k, v in tracked_balances.items() if k != 'USDT'} if holdings: print(f'\nActive Holdings:') for asset, qty in sorted(holdings.items()): print(f' {asset}: {qty:.8f}') else: print('Active Holdings: NONE') # 3. Open orders (FRESH) orders = client.get_open_orders() print(f'\nOpen Orders (Pending): {len(orders)}') for o in orders: print(f' - {o["symbol"]}: {o["side"]} {o["origQty"]} @ {o["price"]}') # 4. Bot state (active_trades.json) try: with open('/home/marc/bot-deploy/active_trades.json') as f: bot_state = json.load(f) print(f'\nBot Active Trades: {bot_state.get("count", 0)}') for symbol, trade in bot_state.get('active_trades', {}).items(): print(f' - {symbol}: {trade["qty"]:.8f} @ {trade["entry_price"]:.2f}') except Exception as e: print(f'Bot State: ERROR - {e}') bot_state = {} # 5. Verification print('\nāœ… VERIFICATION:') if len(holdings) == bot_state.get('count', 0): print(f' āœ… Holdings ({len(holdings)}) matches Bot ({bot_state.get("count")}) āœ…') else: print(f' āš ļø MISMATCH: Holdings={len(holdings)} vs Bot={bot_state.get("count")}') # 6. Check for garbage/orphaned coins garbage = {k: v for k, v in balances.items() if k not in TRACKED_ASSETS and v > 0.0001} if garbage: print(f'\nāš ļø GARBAGE/ORPHANED COINS:') for asset, qty in sorted(garbage.items()): print(f' {asset}: {qty:.8f} (not tracked by bot)') print('='*70) except Exception as e: print(f'ERROR: {e}') if __name__ == '__main__': get_live_data()