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/reports/LOGGING_GUIDE.py from GaryLeckey/aureon-os: direct link, hf CLI and curl.
- Browser
- Download file 8.83 kB
-
https://huggingface.co/spaces/GaryLeckey/aureon-os/resolve/main/scripts/reports/LOGGING_GUIDE.py
- Command line
-
hf download hf://spaces/GaryLeckey/aureon-os/scripts/reports/LOGGING_GUIDE.py
-
curl -L -o LOGGING_GUIDE.py https://huggingface.co/spaces/GaryLeckey/aureon-os/resolve/main/scripts/reports/LOGGING_GUIDE.py
8.83 kB
| #!/usr/bin/env python3 | |
| """ | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| π TRADE LOGGING & PROBABILITY MATRIX VALIDATOR π | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| COMPREHENSIVE LOGGING SYSTEM FOR AUREON UNIFIED ECOSYSTEM | |
| This system captures complete trade data for: | |
| β Cross-referencing trader data with market conditions | |
| β Full market sweep verification | |
| β Probability matrix validation (predictions vs actual outcomes) | |
| β HNC frequency harmonics correlation with profitability | |
| β ML training data generation | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| """ | |
| from aureon_baton_link import link_system as _baton_link; _baton_link(__name__) | |
| print(__doc__) | |
| print("\n" + "="*80) | |
| print("π QUICK START GUIDE".center(80)) | |
| print("="*80) | |
| guide = """ | |
| 1οΈβ£ COMPONENTS | |
| ββ trade_logger.py - Main logging engine (TradeLogger class) | |
| ββ trade_analyzer.py - Data analysis & validation (TradeDataAnalyzer) | |
| ββ run_ecosystem_with_logging.py - Integration script | |
| ββ aureon_unified_ecosystem.py - Updated with logging hooks | |
| 2οΈβ£ START THE ECOSYSTEM WITH LOGGING | |
| Basic run (1 hour, 5s cycles, Β£50 target): | |
| $ python3 run_ecosystem_with_logging.py | |
| Or direct usage: | |
| $ from aureon_unified_ecosystem import AurisEngine | |
| $ engine = AurisEngine() | |
| $ engine.run(interval=5.0, target_profit_gbp=50, max_minutes=60) | |
| 3οΈβ£ OUTPUT FILES (saved in /tmp/aureon_trade_logs/) | |
| trades_YYYYMMDD_HHMMSS.jsonl | |
| ββ Every trade entry with full metadata | |
| ββ Fields: symbol, entry_price, quantity, coherence, HNC frequency, etc. | |
| ββ One JSON object per line (JSONL format) | |
| exits_YYYYMMDD_HHMMSS.jsonl | |
| ββ Every trade exit | |
| ββ Fields: exit_price, P&L, fees, hold_time, exit_reason | |
| ββ Linked to entries via trade_id | |
| validations_YYYYMMDD_HHMMSS.jsonl | |
| ββ Probability predictions vs actual outcomes | |
| ββ 1m and 5m forecast validation | |
| ββ For ML training | |
| market_sweep_YYYYMMDD_HHMMSS.jsonl | |
| ββ Full market conditions per cycle | |
| ββ Opportunities found/rejected | |
| ββ Frequency distribution, coherence levels | |
| training_data_YYYYMMDD_HHMMSS.jsonl | |
| ββ Combined dataset ready for ML | |
| ββ All trades merged with exits and validations | |
| ββ Sorted and ready for analysis | |
| 4οΈβ£ ANALYZE THE DATA | |
| Basic analysis: | |
| $ python3 trade_analyzer.py /tmp/aureon_trade_logs/trades_*.jsonl | |
| Or in Python: | |
| $ from trade_analyzer import TradeDataAnalyzer | |
| $ analyzer = TradeDataAnalyzer('trades_*.jsonl', 'exits_*.jsonl') | |
| $ analyzer.print_summary() | |
| Available methods: | |
| ββ get_market_sweep_completeness() - Full coverage check | |
| ββ get_probability_accuracy() - Win rate by frequency/coherence | |
| ββ get_frequency_profitability() - Which frequencies work best | |
| ββ get_node_performance() - Auris node effectiveness | |
| ββ get_gate_effectiveness() - Gate threshold analysis | |
| ββ generate_report() - Full JSON report | |
| ββ print_summary() - Human-readable summary | |
| 5οΈβ£ KEY INSIGHTS FROM DATA | |
| The logging system validates: | |
| β MARKET SWEEP COMPLETENESS | |
| - Were all viable opportunities found? | |
| - How many were rejected and why? | |
| - Node distribution across opportunities | |
| β PROBABILITY MATRIX ACCURACY | |
| - Do 1m/5m forecasts match actual outcomes? | |
| - Which frequency bands are most predictive? | |
| - Coherence level correlation with wins | |
| β HNC FREQUENCY EFFECTIVENESS | |
| - 256Hz (Harmonic) profitability | |
| - 440Hz (Distortion) impact | |
| - Frequency shifting correlation with exits | |
| β GATE EFFECTIVENESS | |
| - MIN_COHERENCE threshold validation | |
| - MIN_GATES requirement analysis | |
| - Score threshold correlation with P&L | |
| β NODE PERFORMANCE | |
| - Which Auris nodes drive profits? | |
| - Node coherence correlation | |
| - Best performing node by strategy | |
| 6οΈβ£ ML TRAINING DATA | |
| Combined training_data_YYYYMMDD_HHMMSS.jsonl contains: | |
| Per trade: | |
| { | |
| "symbol": "BTCUSD", | |
| "entry_price": 95000.0, | |
| "exit_price": 96140.0, | |
| "coherence": 0.65, | |
| "hnc_frequency": 256, | |
| "hnc_is_harmonic": true, | |
| "probability_score": 0.72, | |
| "dominant_node": "Tiger", | |
| "net_pnl": 1.12, | |
| "pnl_pct": 1.2, | |
| "hold_time_seconds": 180, | |
| "gates_passed": 3, | |
| "reason": "TP" | |
| } | |
| Use this for training predictive models! | |
| 7οΈβ£ EXAMPLE: PROBABILITY MATRIX CALIBRATION | |
| After collecting trades, validate the probability matrix: | |
| $ analyzer = TradeDataAnalyzer(trades_file, exits_file, validations_file) | |
| $ accuracy = analyzer.get_probability_accuracy() | |
| Results by frequency: | |
| { | |
| "256": {"correct": 8, "total": 12, "accuracy": 66.7}, | |
| "528": {"correct": 5, "total": 7, "accuracy": 71.4}, | |
| "440": {"correct": 2, "total": 8, "accuracy": 25.0} | |
| } | |
| => 256Hz and 528Hz are good! 440Hz needs adjustment. | |
| 8οΈβ£ EXAMPLE: GATE THRESHOLD VALIDATION | |
| $ gate_eff = analyzer.get_gate_effectiveness() | |
| Results: | |
| { | |
| "2": {"avg_pnl": 1.2, "win_rate": 75%, "trades": 12}, | |
| "3": {"avg_pnl": 0.8, "win_rate": 60%, "trades": 8}, | |
| "4": {"avg_pnl": 0.3, "win_rate": 40%, "trades": 5} | |
| } | |
| => 2 gates optimal! Increasing gates hurts performance. | |
| 9οΈβ£ DATABASE INTEGRATION (Future) | |
| Export data to database: | |
| $ import sqlite3 | |
| $ from trade_analyzer import TradeDataAnalyzer | |
| $ analyzer = TradeDataAnalyzer(...) | |
| $ # Insert into DB for long-term tracking | |
| π TROUBLESHOOTING | |
| β No log files created? | |
| ββ Check TRADE_LOGGER_AVAILABLE flag in ecosystem | |
| ββ Verify /tmp/aureon_trade_logs/ is writable | |
| ββ Check logger initialization: get_trade_logger() | |
| β Incomplete data in exits? | |
| ββ Trade may still be open (not exited yet) | |
| ββ Log shows 'pending_trades' count | |
| ββ Come back after positions close | |
| β Analysis shows low accuracy? | |
| ββ May need more data (min 50+ trades) | |
| ββ Check if frequency bands are properly set | |
| ββ Verify coherence calculations | |
| β Training data format wrong? | |
| ββ Check JSONL format (one JSON per line) | |
| ββ Use export_training_data() from logger | |
| ββ Validate with: cat file.jsonl | python3 -m json.tool | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| """ | |
| print(guide) | |
| print("\n" + "="*80) | |
| print("π FILE LOCATIONS".center(80)) | |
| print("="*80) | |
| import os | |
| from pathlib import Path | |
| log_dir = Path('/tmp/aureon_trade_logs') | |
| log_dir.mkdir(parents=True, exist_ok=True) | |
| print(f"\nπ Main directory: {log_dir}") | |
| print(f" Status: {'β EXISTS' if log_dir.exists() else 'β NOT FOUND'}") | |
| # List any existing logs | |
| existing_logs = list(log_dir.glob('*.jsonl')) | |
| if existing_logs: | |
| print(f"\nπ Existing log files ({len(existing_logs)}):") | |
| for logfile in sorted(existing_logs)[-5:]: # Show last 5 | |
| size_mb = logfile.stat().st_size / (1024 * 1024) | |
| mtime = logfile.stat().st_mtime | |
| from datetime import datetime | |
| time_str = datetime.fromtimestamp(mtime).strftime('%Y-%m-%d %H:%M:%S') | |
| print(f" {logfile.name:45s} | {size_mb:8.2f} MB | {time_str}") | |
| else: | |
| print("\nπ No log files yet (will be created on first run)") | |
| print("\n" + "="*80) | |
| print("β LOGGING SYSTEM READY!".center(80)) | |
| print("="*80) | |
| print("\nπ‘ Next steps:") | |
| print(" 1. Run: python3 run_ecosystem_with_logging.py") | |
| print(" 2. Wait for trades to complete") | |
| print(" 3. Analyze: python3 trade_analyzer.py /tmp/aureon_trade_logs/trades_*.jsonl") | |
| print("\n") | |