Spaces:
Running
Running
Deploy Aureon OS (deploy/selfhost stack: nginx edge + fusion API x2 + console + HNC organ + redis + postgres; paper mode) (part 19)
da0ce7b verified Download scripts/python/monitor_ecosystem.py from GaryLeckey/aureon-os: direct link, hf CLI and curl.
- Browser
- Download file 7.1 kB
-
https://huggingface.co/spaces/GaryLeckey/aureon-os/resolve/main/scripts/python/monitor_ecosystem.py
- Command line
-
hf download hf://spaces/GaryLeckey/aureon-os/scripts/python/monitor_ecosystem.py
-
curl -L -o monitor_ecosystem.py https://huggingface.co/spaces/GaryLeckey/aureon-os/resolve/main/scripts/python/monitor_ecosystem.py
7.1 kB
| #!/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() | |