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")