Spaces:
Running
Running
File size: 8,825 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 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 | #!/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")
|