File size: 7,104 Bytes
da0ce7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""

╔════════════════════════════════════════════════════════════════════════════════════════╗

β•‘                                                                                        β•‘

β•‘                  πŸ“Š LIVE ECOSYSTEM MONITORING DASHBOARD πŸ“Š                            β•‘

β•‘                                                                                        β•‘

β•‘     Real-time tracking of:                                                            β•‘

β•‘       β€’ Trade data collection progress                                                β•‘

β•‘       β€’ Frequency distribution of trades                                              β•‘

β•‘       β€’ Node performance tracking                                                     β•‘

β•‘       β€’ Market sweep validation                                                       β•‘

β•‘       β€’ Probability matrix correlation                                                β•‘

β•‘                                                                                        β•‘

β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

"""

from aureon_baton_link import link_system as _baton_link; _baton_link(__name__)
import os
import json
import time
from pathlib import Path
from collections import defaultdict
import statistics

def monitor_logs(log_dir="/tmp/aureon_trade_logs"):
    """Monitor trade logs in real-time"""
    
    log_dir = Path(log_dir)
    if not log_dir.exists():
        print("❌ Log directory not found")
        return
    
    # Find the latest trades file
    trades_files = sorted(log_dir.glob("trades_*.jsonl"))
    if not trades_files:
        print("❌ No trade logs found yet")
        return
    
    latest_trades_file = trades_files[-1]
    latest_exits_file = Path(str(latest_trades_file).replace("trades_", "exits_"))
    latest_sweep_file = Path(str(latest_trades_file).replace("trades_", "market_sweep_"))
    
    print("\n" + "="*80)
    print("πŸ“Š LIVE ECOSYSTEM MONITORING DASHBOARD".center(80))
    print("="*80)
    
    # Read trades
    trades = []
    if latest_trades_file.exists():
        with open(latest_trades_file) as f:
            for line in f:
                try:
                    trades.append(json.loads(line))
                except:
                    pass
    
    # Read exits
    exits = []
    if latest_exits_file.exists():
        with open(latest_exits_file) as f:
            for line in f:
                try:
                    exits.append(json.loads(line))
                except:
                    pass
    
    # Read market sweeps
    sweeps = []
    if latest_sweep_file.exists():
        with open(latest_sweep_file) as f:
            for line in f:
                try:
                    sweeps.append(json.loads(line))
                except:
                    pass
    
    print(f"\n⏱️  Last Updated: {time.strftime('%H:%M:%S')}")
    print(f"πŸ“ Log File: {latest_trades_file.name}")
    
    # Trade Statistics
    print(f"\nπŸ“ˆ TRADE COLLECTION PROGRESS:")
    print(f"   β€’ Trades Entered: {len(trades)}")
    print(f"   β€’ Trades Exited: {len(exits)}")
    print(f"   β€’ Pending Trades: {len(trades) - len(exits)}")
    
    if exits:
        total_pnl = sum(e.get('net_pnl', 0) for e in exits)
        wins = sum(1 for e in exits if e.get('net_pnl', 0) > 0)
        win_rate = (wins / len(exits) * 100) if exits else 0
        
        print(f"\nπŸ’° PROFITABILITY:")
        print(f"   β€’ Total P&L: ${total_pnl:+.2f}")
        print(f"   β€’ Win Rate: {win_rate:.1f}% ({wins}/{len(exits)})")
        print(f"   β€’ Avg P&L per trade: ${total_pnl/len(exits):+.2f}")
    
    # Frequency Analysis
    if trades:
        freq_dist = defaultdict(int)
        for trade in trades:
            freq = trade.get('hnc_frequency', 0)
            freq_dist[freq] += 1
        
        print(f"\nπŸ”Š HNC FREQUENCY DISTRIBUTION:")
        for freq in sorted(freq_dist.keys()):
            count = freq_dist[freq]
            bar = "β–ˆ" * min(20, count)
            print(f"   {freq:4.0f}Hz: {count:3d} trades {bar}")
    
    # Node Performance
    if trades:
        node_dist = defaultdict(lambda: {'count': 0, 'coherence': []})
        for trade in trades:
            node = trade.get('dominant_node', 'Unknown')
            node_dist[node]['count'] += 1
            node_dist[node]['coherence'].append(trade.get('coherence', 0.5))
        
        print(f"\n🎯 NODE DISTRIBUTION:")
        for node in sorted(node_dist.keys()):
            data = node_dist[node]
            avg_coherence = statistics.mean(data['coherence']) if data['coherence'] else 0
            print(f"   {node:15s}: {data['count']:3d} trades | Ξ“_avg: {avg_coherence:.2f}")
    
    # Market Sweep Statistics
    if sweeps:
        total_found = sum(s.get('total_opportunities_found', 0) for s in sweeps)
        total_entered = sum(s.get('opportunities_entered', 0) for s in sweeps)
        total_rejected = sum(s.get('opportunities_rejected', 0) for s in sweeps)
        avg_coherence = statistics.mean([s.get('average_coherence', 0.5) for s in sweeps])
        
        print(f"\n🌍 MARKET SWEEP ANALYSIS:")
        print(f"   β€’ Total Opportunities Found: {total_found}")
        print(f"   β€’ Opportunities Entered: {total_entered}")
        print(f"   β€’ Opportunities Rejected: {total_rejected}")
        print(f"   β€’ Entry Rate: {(total_entered/total_found*100) if total_found > 0 else 0:.1f}%")
        print(f"   β€’ Average Coherence: {avg_coherence:.2f}")
        print(f"   β€’ Sweeps Completed: {len(sweeps)}")
    
    # Progress toward 50+ trades goal
    target_trades = 50
    current_trades = len(trades)
    progress_pct = (current_trades / target_trades * 100) if target_trades > 0 else 0
    bar_length = 30
    filled = int(bar_length * progress_pct / 100)
    bar = "β–ˆ" * filled + "β–‘" * (bar_length - filled)
    
    print(f"\n🎯 PROGRESS TOWARD 50-TRADE COLLECTION TARGET:")
    print(f"   [{bar}] {progress_pct:.1f}% ({current_trades}/{target_trades})")
    
    if current_trades > 0:
        time_per_trade = 0.5  # Rough estimate
        remaining_trades = max(0, target_trades - current_trades)
        eta_seconds = remaining_trades * time_per_trade
        eta_minutes = eta_seconds / 60
        print(f"   ⏱️  ETA: ~{eta_minutes:.1f} minutes ({remaining_trades} trades remaining)")
    
    print("\n" + "="*80)
    print("\n✨ Dashboard updated successfully")

if __name__ == '__main__':
    monitor_logs()