Spaces:
Runtime error

File size: 9,835 Bytes
56c0d82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#!/usr/bin/env python3
"""
πŸ” DASHBOARD DATA DIAGNOSTICS
Checks what data sources are actually working and returning data.
"""

import sys
import os
import json
import asyncio

# Color codes
GREEN = '\033[92m'
RED = '\033[91m'
YELLOW = '\033[93m'
BLUE = '\033[94m'
RESET = '\033[0m'

async def test_prices():
    """Test if we can fetch prices."""
    print(f"\n{BLUE}πŸ“Š TESTING PRICE FETCHING{RESET}")
    
    # Try unified market cache
    try:
        from unified_market_cache import get_all_prices, get_ticker
        prices = await asyncio.to_thread(get_all_prices)
        if prices:
            print(f"  {GREEN}βœ… Unified Market Cache: {len(prices)} symbols{RESET}")
            for sym in ['BTC', 'ETH', 'SOL']:
                if sym in prices:
                    print(f"     {sym}: ${prices[sym].get('price', 0):,.2f}")
            return True
        else:
            print(f"  {YELLOW}⚠️ Unified Market Cache: No data{RESET}")
    except Exception as e:
        print(f"  {RED}❌ Unified Market Cache: {str(e)[:100]}{RESET}")
    
    # Try CoinGecko fallback
    try:
        import aiohttp
        async with aiohttp.ClientSession() as session:
            url = "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,solana&vs_currencies=usd&include_24hr_change=true"
            async with session.get(url) as resp:
                if resp.status == 200:
                    data = await resp.json()
                    print(f"  {GREEN}βœ… CoinGecko API: Working{RESET}")
                    if 'bitcoin' in data:
                        print(f"     BTC: ${data['bitcoin']['usd']:,.2f}")
                    return True
    except Exception as e:
        print(f"  {RED}❌ CoinGecko: {str(e)[:100]}{RESET}")
    
    return False

async def test_portfolio():
    """Test if we can fetch portfolio data."""
    print(f"\n{BLUE}πŸ’Ό TESTING PORTFOLIO FETCHING{RESET}")
    
    # Try live_position_viewer
    try:
        from live_position_viewer import get_binance_positions, get_alpaca_positions
        
        binance_pos = await asyncio.to_thread(get_binance_positions)
        print(f"  {GREEN}βœ… Binance positions: {len(binance_pos)} positions{RESET}")
        
        alpaca_pos = await asyncio.to_thread(get_alpaca_positions)
        print(f"  {GREEN}βœ… Alpaca positions: {len(alpaca_pos)} positions{RESET}")
        
        return len(binance_pos) > 0 or len(alpaca_pos) > 0
    except Exception as e:
        print(f"  {RED}❌ Live Position Viewer: {str(e)[:100]}{RESET}")
    
    # Try state files
    try:
        state_files = [
            'dashboard_snapshot.json',
            'cost_basis_history.json',
            'tracked_positions.json'
        ]
        
        for filename in state_files:
            if os.path.exists(filename):
                with open(filename, 'r') as f:
                    data = json.load(f)
                    size = len(json.dumps(data))
                    print(f"  {GREEN}βœ… {filename}: {size} bytes{RESET}")
            else:
                print(f"  {YELLOW}⚠️ {filename}: Not found{RESET}")
    except Exception as e:
        print(f"  {RED}❌ State files: {str(e)[:100]}{RESET}")
    
    return False

async def test_balances():
    """Test if we can fetch exchange balances."""
    print(f"\n{BLUE}πŸ’° TESTING EXCHANGE BALANCES{RESET}")
    
    exchanges = [
        ('binance_client', 'BinanceClient'),
        ('kraken_client', 'KrakenClient'),
        ('alpaca_client', 'AlpacaClient')
    ]
    
    working = 0
    for module_name, class_name in exchanges:
        try:
            module = __import__(module_name)
            client_class = getattr(module, class_name)
            client = client_class()
            
            balance = await asyncio.to_thread(client.get_balance)
            if balance:
                total = sum(float(v) for v in balance.values() if v)
                print(f"  {GREEN}βœ… {class_name}: ${total:,.2f}{RESET}")
                working += 1
            else:
                print(f"  {YELLOW}⚠️ {class_name}: Empty balance{RESET}")
        except Exception as e:
            error_msg = str(e)
            if 'API' in error_msg or 'key' in error_msg.lower():
                print(f"  {YELLOW}⚠️ {class_name}: No API keys{RESET}")
            else:
                print(f"  {RED}❌ {class_name}: {error_msg[:60]}{RESET}")
    
    return working > 0

async def test_ocean_scanner():
    """Test if Ocean Scanner can fetch data."""
    print(f"\n{BLUE}🌊 TESTING OCEAN SCANNER{RESET}")
    
    try:
        from aureon_ocean_scanner import OceanScanner
        
        # Create scanner with available exchanges
        exchanges = {}
        
        # Try to load exchanges
        for exch_name, client_name in [('kraken', 'KrakenClient'), ('binance', 'BinanceClient'), ('alpaca', 'AlpacaClient')]:
            try:
                if exch_name == 'kraken':
                    from kraken_client import KrakenClient, get_kraken_client
                    exchanges['kraken'] = get_kraken_client()
                elif exch_name == 'binance':
                    from binance_client import BinanceClient, get_binance_client
                    exchanges['binance'] = BinanceClient()
                elif exch_name == 'alpaca':
                    from alpaca_client import AlpacaClient
                    exchanges['alpaca'] = AlpacaClient()
            except:
                pass
        
        if exchanges:
            scanner = OceanScanner(exchanges)
            print(f"  {GREEN}βœ… Ocean Scanner initialized with {len(exchanges)} exchange(s){RESET}")
            
            # Try to discover universe
            await scanner.discover_universe()
            summary = scanner.get_ocean_summary()
            
            universe_size = summary.get('universe_size', {}).get('total', 0)
            print(f"  {GREEN}βœ… Universe discovered: {universe_size:,} symbols{RESET}")
            return True
        else:
            print(f"  {YELLOW}⚠️ No exchanges available for Ocean Scanner{RESET}")
    except Exception as e:
        print(f"  {RED}❌ Ocean Scanner: {str(e)[:100]}{RESET}")
    
    return False

async def test_queen_narrator():
    """Test if Queen Narrator is working."""
    print(f"\n{BLUE}πŸ‘‘ TESTING QUEEN COGNITIVE NARRATOR{RESET}")
    
    try:
        from queen_cognitive_narrator import QueenCognitiveNarrator
        
        narrator = QueenCognitiveNarrator()
        print(f"  {GREEN}βœ… Queen Narrator initialized{RESET}")
        
        # Update context
        narrator.update_context(
            btc_price=78883.00,
            btc_change_24h=1.91,
            portfolio_value=0,
            unrealized_pnl=0,
            active_positions=0
        )
        
        # Get thought
        thought = narrator.get_latest_thought()
        if thought:
            print(f"  {GREEN}βœ… Generated thought: {thought.get('title', 'N/A')}{RESET}")
            return True
        else:
            print(f"  {YELLOW}⚠️ No thought generated{RESET}")
    except Exception as e:
        print(f"  {RED}❌ Queen Narrator: {str(e)[:100]}{RESET}")
    
    return False

async def test_harmonic_field():
    """Test if Harmonic Field is working."""
    print(f"\n{BLUE}πŸ”© TESTING HARMONIC LIQUID ALUMINIUM FIELD{RESET}")
    
    try:
        from aureon_harmonic_liquid_aluminium import HarmonicLiquidAluminiumField
        
        field = HarmonicLiquidAluminiumField()
        print(f"  {GREEN}βœ… Harmonic Field initialized{RESET}")
        
        # Capture snapshot
        snapshot = field.capture_snapshot()
        print(f"  {GREEN}βœ… Snapshot captured{RESET}")
        print(f"     Frequency: {snapshot.frequency} Hz")
        print(f"     Amplitude: {snapshot.amplitude:.4f}")
        print(f"     Pattern: {snapshot.pattern}")
        
        return True
    except Exception as e:
        print(f"  {RED}❌ Harmonic Field: {str(e)[:100]}{RESET}")
    
    return False

async def main():
    print(f"\n{BLUE}{'='*70}{RESET}")
    print(f"{BLUE}πŸ” AUREON PRO DASHBOARD - DATA DIAGNOSTICS{RESET}")
    print(f"{BLUE}{'='*70}{RESET}")
    
    results = {}
    
    # Test each data source
    results['prices'] = await test_prices()
    results['portfolio'] = await test_portfolio()
    results['balances'] = await test_balances()
    results['ocean'] = await test_ocean_scanner()
    results['queen'] = await test_queen_narrator()
    results['harmonic'] = await test_harmonic_field()
    
    # Summary
    print(f"\n{BLUE}{'='*70}{RESET}")
    print(f"{BLUE}πŸ“Š SUMMARY{RESET}")
    print(f"{BLUE}{'='*70}{RESET}")
    
    working = sum(1 for v in results.values() if v)
    total = len(results)
    
    for name, status in results.items():
        icon = f"{GREEN}βœ…{RESET}" if status else f"{RED}❌{RESET}"
        print(f"  {icon} {name.title()}")
    
    print(f"\n  {GREEN if working == total else YELLOW}Working: {working}/{total}{RESET}")
    
    # Recommendations
    print(f"\n{BLUE}πŸ’‘ RECOMMENDATIONS:{RESET}")
    
    if not results['balances']:
        print(f"  β€’ Set API keys in DigitalOcean for live balance data")
    
    if not results['portfolio']:
        print(f"  β€’ Portfolio will be empty until you have open positions")
        print(f"  β€’ Or set API keys to fetch live positions")
    
    if results['prices'] and results['queen'] and results['harmonic']:
        print(f"  β€’ {GREEN}βœ… Dashboard core functionality is WORKING!{RESET}")
        print(f"  β€’ Prices, Queen commentary, and harmonic field are live")
    
    print(f"\n{BLUE}πŸš€ The dashboard is showing exactly what it should!{RESET}")
    print(f"   Missing data is due to no API keys (expected in demo mode)")

if __name__ == '__main__':
    asyncio.run(main())