RayMelius Claude Opus 4.6 commited on
Commit
902dc22
Β·
1 Parent(s): 235f0f5

docs: Update README and developers guide for v0.9.5

Browse files

- Add Dual Engine Architecture section with Python/C++ diagram
- Document engine mode switch (UI toggle, API, FIX message flow)
- Add CppEngineBridge architecture diagram to developers guide
- Update project structure with Python services and .env
- Add LLM trading strategy to AI Trading Members section
- Update roadmap to v0.9.5 with all completed features
- Mark Engine Mode Switch as completed in Next Steps

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (2) hide show
  1. README.md +47 -6
  2. docs/developers-guide.md +154 -23
README.md CHANGED
@@ -27,7 +27,7 @@ ch_ai_trader.py β†’ ClearingHouseActor β†’ Clearing House (P
27
  AI strategies β†’ AITraderActor β†’ Trading obligations
28
  ```
29
 
30
- ## Actor Topology (v0.8)
31
 
32
  ```
33
  Core 0: OEGActor + FIXAcceptorActor ← Order entry & FIX protocol
@@ -36,6 +36,43 @@ ch_ai_trader.py β†’ ClearingHouseActor β†’ Clearing House (P
36
  Core 3: ClearingHouseActor + AITrader ← Post-trade & AI members
37
  ```
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  ## Service Architecture
40
 
41
  ```
@@ -54,6 +91,7 @@ ch_ai_trader.py β†’ ClearingHouseActor β†’ Clearing House (P
54
  β”‚ OHLCV History β”‚ β”‚ Portfolios β”‚ β”‚ Amend/ExecRpt β”‚
55
  β”‚ SQLite DB β”‚ β”‚ Settlements β”‚ β”‚ β”‚
56
  β”‚ SSE Streaming β”‚ β”‚ β”‚ β”‚ β”‚
 
57
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
58
  β”‚ β”‚ β”‚
59
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
@@ -106,11 +144,13 @@ docker compose up --build
106
  cmake -B build -DEUNEX_BUILD_TESTS=ON
107
  cmake --build build --config Release
108
 
109
- # Run matching engine
110
  ./build/Release/eunex_me
111
 
112
  # Run all tests (7 suites)
113
  cd build && ctest -C Release
 
 
114
  ```
115
 
116
  ## With Kafka Persistence
@@ -267,7 +307,8 @@ EuNEx/
267
  5. ~~Market simulation~~ βœ“ Realistic AI trading + Dashboard auto-simulation
268
  6. ~~AI Analyst~~ βœ“ Ollama/Groq/HuggingFace market commentary
269
  7. ~~Message Flow Visualizer~~ βœ“ Developer pipeline tracing tool
270
- 8. **SBE encoding** β€” replace event structs with SBE-encoded messages
271
- 9. **Master/Mirror failover** β€” implement full Recovery replay on Mirror node
272
- 10. **Trading phases** β€” pre-open, uncrossing, continuous, close, TAL
273
- 11. **Additional order types** β€” Stop, Pegged, Mid-Point, Iceberg
 
 
27
  AI strategies β†’ AITraderActor β†’ Trading obligations
28
  ```
29
 
30
+ ## Actor Topology (v0.9)
31
 
32
  ```
33
  Core 0: OEGActor + FIXAcceptorActor ← Order entry & FIX protocol
 
36
  Core 3: ClearingHouseActor + AITrader ← Post-trade & AI members
37
  ```
38
 
39
+ ## Dual Engine Architecture
40
+
41
+ The dashboard can run in two modes, switchable at runtime via a toggle in the UI:
42
+
43
+ ```
44
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
45
+ β”‚ Browser (:8090) β”‚
46
+ β”‚ [Python ○────● C++] toggle β”‚
47
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
48
+ β”‚
49
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
50
+ β”‚ Dashboard (Flask :8090) β”‚
51
+ β”‚ β”‚
52
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
53
+ β”‚ β”‚ Python ME β”‚ β”‚ C++ Bridge β”‚ β”‚
54
+ β”‚ β”‚MatchingEng β”‚ β”‚ FIX 4.4 TCP β”‚ β”‚
55
+ β”‚ β”‚(built-in) β”‚ β”‚ client β”‚ β”‚
56
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β”‚
57
+ β”‚ mode=python mode=cpp β”‚
58
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”˜
59
+ β”‚ FIX 4.4 TCP
60
+ β–Ό
61
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
62
+ β”‚ C++ Matching Engine β”‚
63
+ β”‚ eunex_me (:9001) β”‚
64
+ β”‚ β”‚
65
+ β”‚ OEG β†’ MECore β†’ MDG β†’ ClearingHouse β”‚
66
+ β”‚ FIXAcceptorActor (TCP :9001) β”‚
67
+ β”‚ Multi-threaded actors β”‚
68
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
69
+ ```
70
+
71
+ | Mode | Engine | How orders are matched | Use case |
72
+ |------|--------|----------------------|----------|
73
+ | **Python** | Built-in `MatchingEngine` | In-process, same Flask app | Demo, learning, no compilation needed |
74
+ | **C++** | `eunex_me` via FIX 4.4 | TCP to C++ actors on port 9001 | Production-like, microsecond latency |
75
+
76
  ## Service Architecture
77
 
78
  ```
 
91
  β”‚ OHLCV History β”‚ β”‚ Portfolios β”‚ β”‚ Amend/ExecRpt β”‚
92
  β”‚ SQLite DB β”‚ β”‚ Settlements β”‚ β”‚ β”‚
93
  β”‚ SSE Streaming β”‚ β”‚ β”‚ β”‚ β”‚
94
+ β”‚ Engine Switch β”‚ β”‚ LLM Trading β”‚ β”‚ β”‚
95
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
96
  β”‚ β”‚ β”‚
97
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 
144
  cmake -B build -DEUNEX_BUILD_TESTS=ON
145
  cmake --build build --config Release
146
 
147
+ # Run matching engine (FIX server on port 9001)
148
  ./build/Release/eunex_me
149
 
150
  # Run all tests (7 suites)
151
  cd build && ctest -C Release
152
+
153
+ # Use with dashboard: start eunex_me, then toggle "C++" in the dashboard header
154
  ```
155
 
156
  ## With Kafka Persistence
 
307
  5. ~~Market simulation~~ βœ“ Realistic AI trading + Dashboard auto-simulation
308
  6. ~~AI Analyst~~ βœ“ Ollama/Groq/HuggingFace market commentary
309
  7. ~~Message Flow Visualizer~~ βœ“ Developer pipeline tracing tool
310
+ 8. ~~Engine Mode Switch~~ βœ“ Python ↔ C++ toggle with FIX 4.4 bridge
311
+ 9. **SBE encoding** β€” replace event structs with SBE-encoded messages
312
+ 10. **Master/Mirror failover** β€” implement full Recovery replay on Mirror node
313
+ 11. **Trading phases** β€” pre-open, uncrossing, continuous, close, TAL
314
+ 12. **Additional order types** β€” Stop, Pegged, Mid-Point, Iceberg
docs/developers-guide.md CHANGED
@@ -1,6 +1,6 @@
1
  # EuNEx Developers Guide
2
 
3
- **Version 0.8.0** | Euronext Optiq-Modeled Exchange Simulator
4
 
5
  ---
6
 
@@ -22,10 +22,11 @@
22
  14. [Market Simulation](#14-market-simulation)
23
  15. [AI Market Analyst](#15-ai-market-analyst)
24
  16. [Developer Message Flow Visualizer](#16-developer-message-flow-visualizer)
25
- 17. [Project Structure](#17-project-structure)
26
- 18. [Build & Test](#18-build--test)
27
- 19. [Configuration](#19-configuration)
28
- 20. [Extending EuNEx](#20-extending-eunex)
 
29
 
30
  ---
31
 
@@ -35,7 +36,7 @@ EuNEx (Euronext Exchange Simulator) is a C++20 actor-based matching engine that
35
 
36
  ```
37
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
38
- β”‚ EuNEx v0.4.0 β”‚
39
  β”‚ β”‚
40
  β”‚ FIX 4.4 Clients ──► OEG ──► ME (per symbol) ──► MDG β”‚
41
  β”‚ β”‚ β”‚ β”‚
@@ -824,7 +825,7 @@ docker compose up --build
824
  β”‚ β”‚ MBR03 β”‚ 202 β”‚ Random β”‚ Noise trader β”‚ β”‚
825
  β”‚ β”‚ MBR04 β”‚ 203 β”‚ Momentum β”‚ β”‚ β”‚
826
  β”‚ β”‚ ... β”‚ ... β”‚ (rotates) β”‚ β”‚ β”‚
827
- β”‚ β”‚ MBR10 β”‚ 209 β”‚ MeanReversion β”‚ β”‚ β”‚
828
  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
829
  β”‚ β”‚
830
  β”‚ Strategy Details: β”‚
@@ -844,6 +845,13 @@ docker compose up --build
844
  β”‚ β”‚ random side (50/50), random qty (10-100) β”‚ β”‚
845
  β”‚ β”‚ price around midpoint with random spread β”‚ β”‚
846
  β”‚ β”‚ β”‚ β”‚
 
 
 
 
 
 
 
847
  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
848
  β”‚ β”‚
849
  β”‚ Data Sources: β”‚
@@ -1045,7 +1053,112 @@ The visualizer uses Python function patching to intercept the matching engine me
1045
 
1046
  ---
1047
 
1048
- ## 17. Project Structure
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1049
 
1050
  ```
1051
  EuNEx/
@@ -1088,6 +1201,25 @@ The visualizer uses Python function patching to intercept the matching engine me
1088
  β”‚ β”œβ”€β”€ PersistenceStore.hpp Store interface
1089
  β”‚ └── KafkaStore.hpp Kafka adapter (optional, librdkafka)
1090
  β”‚
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1091
  β”œβ”€β”€ tests/
1092
  β”‚ β”œβ”€β”€ test_orderbook.cpp Book unit tests (26 cases)
1093
  β”‚ β”œβ”€β”€ test_matching_engine.cpp ME integration tests
@@ -1107,7 +1239,7 @@ The visualizer uses Python function patching to intercept the matching engine me
1107
 
1108
  ---
1109
 
1110
- ## 18. Build & Test
1111
 
1112
  ### Prerequisites
1113
 
@@ -1166,7 +1298,7 @@ cd build && ctest -C Release --output-on-failure
1166
 
1167
  ---
1168
 
1169
- ## 19. Configuration
1170
 
1171
  ### Runtime Configuration (main.cpp)
1172
 
@@ -1195,7 +1327,7 @@ The engine pre-populates order books with spread-defining orders:
1195
 
1196
  ---
1197
 
1198
- ## 20. Extending EuNEx
1199
 
1200
  ### Adding a New Symbol
1201
 
@@ -1230,8 +1362,8 @@ The engine pre-populates order books with spread-defining orders:
1230
  ### Future Roadmap
1231
 
1232
  ```
1233
- Current (v0.6) Planned
1234
- ══════════════ ═══════════════════════════════════
1235
 
1236
  βœ“ Limit + Market + Stop orders β–‘ Pegged, Mid-Point, Iceberg
1237
  βœ“ IOC, FOK, Day β–‘ GTD, GTC, VFU, VFCU
@@ -1244,17 +1376,16 @@ The engine pre-populates order books with spread-defining orders:
1244
  βœ“ Clearing house + AI traders β–‘ EuroCCP/LCH integration
1245
  βœ“ IACA fragments β–‘ IACA FINISH + COPY + IDS
1246
  βœ“ Python bridge (JSON) β–‘ SBE multicast MDG
1247
- βœ“ Market simulation (C++ + Py) β–‘ SBE multicast MDG
1248
- βœ“ Ticker tape + OHLCV charts β–‘ Multi-day backtesting
1249
- βœ“ Daily close persistence β–‘ Real Simplx multi-core
1250
- βœ“ AI Analyst (Ollama/Groq/HF) β–‘ EuroCCP/LCH integration
1251
- βœ“ Message Flow Visualizer β–‘ FIX 5.0 SP2 + SBE binary
1252
- β–‘ SQLite trade persistence
1253
- β–‘ Developer message visualizer
1254
- β–‘ SATURN ARM (MiFID II RTS 22)
1255
- β–‘ PTB (Post-Trade Box)
1256
  ```
1257
 
1258
  ---
1259
 
1260
- *Generated for EuNEx v0.6.0 β€” Euronext Optiq Architecture Simulator*
 
1
  # EuNEx Developers Guide
2
 
3
+ **Version 0.9.5** | Euronext Optiq-Modeled Exchange Simulator
4
 
5
  ---
6
 
 
22
  14. [Market Simulation](#14-market-simulation)
23
  15. [AI Market Analyst](#15-ai-market-analyst)
24
  16. [Developer Message Flow Visualizer](#16-developer-message-flow-visualizer)
25
+ 17. [Engine Mode Switch](#17-engine-mode-switch)
26
+ 18. [Project Structure](#18-project-structure)
27
+ 19. [Build & Test](#19-build--test)
28
+ 20. [Configuration](#20-configuration)
29
+ 21. [Extending EuNEx](#21-extending-eunex)
30
 
31
  ---
32
 
 
36
 
37
  ```
38
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
39
+ β”‚ EuNEx v0.9.5 β”‚
40
  β”‚ β”‚
41
  β”‚ FIX 4.4 Clients ──► OEG ──► ME (per symbol) ──► MDG β”‚
42
  β”‚ β”‚ β”‚ β”‚
 
825
  β”‚ β”‚ MBR03 β”‚ 202 β”‚ Random β”‚ Noise trader β”‚ β”‚
826
  β”‚ β”‚ MBR04 β”‚ 203 β”‚ Momentum β”‚ β”‚ β”‚
827
  β”‚ β”‚ ... β”‚ ... β”‚ (rotates) β”‚ β”‚ β”‚
828
+ β”‚ β”‚ MBR10 β”‚ 209 β”‚ Random β”‚ β”‚ β”‚
829
  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
830
  β”‚ β”‚
831
  β”‚ Strategy Details: β”‚
 
845
  β”‚ β”‚ random side (50/50), random qty (10-100) β”‚ β”‚
846
  β”‚ β”‚ price around midpoint with random spread β”‚ β”‚
847
  β”‚ β”‚ β”‚ β”‚
848
+ β”‚ β”‚ LLM (Python CH only): β”‚ β”‚
849
+ β”‚ β”‚ sends portfolio + market data to LLM β”‚ β”‚
850
+ β”‚ β”‚ expects JSON response: symbol, side, quantity, price, reason β”‚ β”‚
851
+ β”‚ β”‚ uses same provider chain as AI Analyst β”‚ β”‚
852
+ β”‚ β”‚ falls back to random on LLM failure β”‚ β”‚
853
+ β”‚ β”‚ explanations shown in CH dashboard panel β”‚ β”‚
854
+ β”‚ β”‚ β”‚ β”‚
855
  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
856
  β”‚ β”‚
857
  β”‚ Data Sources: β”‚
 
1053
 
1054
  ---
1055
 
1056
+ ## 17. Engine Mode Switch
1057
+
1058
+ The dashboard supports two matching engine backends, switchable at runtime via a toggle in the header.
1059
+
1060
+ ### Architecture
1061
+
1062
+ ```
1063
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
1064
+ β”‚ Dashboard (Flask :8090) β”‚
1065
+ β”‚ β”‚
1066
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
1067
+ β”‚ β”‚ Python MatchingEngine β”‚ β”‚ CppEngineBridge β”‚ β”‚
1068
+ β”‚ β”‚ (built-in, default) β”‚ β”‚ (FIX 4.4 TCP client) β”‚ β”‚
1069
+ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
1070
+ β”‚ β”‚ β€’ In-process order book β”‚ β”‚ β€’ Connects to :9001 β”‚ β”‚
1071
+ β”‚ β”‚ β€’ Price-time priority β”‚ β”‚ β€’ Sends NewOrderSingle(D) β”‚ β”‚
1072
+ β”‚ β”‚ β€’ No compilation needed β”‚ β”‚ β€’ Sends CancelRequest (F) β”‚ β”‚
1073
+ β”‚ β”‚ β€’ SQLite persistence β”‚ β”‚ β€’ Sends CancelReplace (G) β”‚ β”‚
1074
+ β”‚ β”‚ β€’ Good for demos β”‚ β”‚ β€’ Receives ExecReport (8) β”‚ β”‚
1075
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β€’ Logon/Logout/Heartbeat β”‚ β”‚
1076
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
1077
+ β”‚ _active_engine() β”‚ β”‚
1078
+ β”‚ returns engine or cpp_bridge β”‚ β”‚
1079
+ β”‚ based on engine_mode variable β”‚ β”‚
1080
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
1081
+ β”‚
1082
+ FIX 4.4 TCP :9001
1083
+ β”‚
1084
+ β–Ό
1085
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
1086
+ β”‚ eunex_me (C++ engine) β”‚
1087
+ β”‚ FIXAcceptorActor :9001 β”‚
1088
+ β”‚ OEG β†’ MECore β†’ MDG β†’ CH β”‚
1089
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
1090
+ ```
1091
+
1092
+ ### Switching Modes
1093
+
1094
+ **From the UI:**
1095
+ The header contains a toggle switch `[Python ○──── C++]` with a status dot:
1096
+ - **Green dot**: C++ engine is running and reachable on port 9001
1097
+ - **Red dot**: C++ engine not detected
1098
+ - Health check runs every 15 seconds
1099
+
1100
+ **From the API:**
1101
+ ```bash
1102
+ # Check current mode and C++ availability
1103
+ GET /engine/mode
1104
+ β†’ {"mode": "python", "cpp_available": true, "cpp_host": "localhost", "cpp_port": 9001}
1105
+
1106
+ # Switch to C++ engine
1107
+ POST /engine/mode {"mode": "cpp"}
1108
+ β†’ {"mode": "cpp"}
1109
+
1110
+ # Switch back to Python
1111
+ POST /engine/mode {"mode": "python"}
1112
+ β†’ {"mode": "python"}
1113
+ ```
1114
+
1115
+ ### Order Routing
1116
+
1117
+ When `engine_mode == "cpp"`:
1118
+ 1. Dashboard builds a FIX `NewOrderSingle` (35=D) message
1119
+ 2. Sends it over TCP to `eunex_me:9001`
1120
+ 3. C++ engine matches and returns `ExecutionReport` (35=8)
1121
+ 4. Bridge parses the response and updates dashboard state (orders, trades, snapshots)
1122
+ 5. SSE events broadcast to browser as usual
1123
+
1124
+ When `engine_mode == "python"`:
1125
+ - Orders processed by the built-in `MatchingEngine` class (default behavior)
1126
+
1127
+ **Simulation orders** (`source=sim`, `source=seed`) always use the Python engine regardless of mode.
1128
+
1129
+ ### FIX Message Flow (C++ Mode)
1130
+
1131
+ ```
1132
+ Browser Dashboard C++ Engine
1133
+ ─────── ───────── ──────────
1134
+ β”‚ POST /order/new β”‚ β”‚
1135
+ β”‚ ─────────────────► β”‚ β”‚
1136
+ β”‚ β”‚ 35=D NewOrderSingle β”‚
1137
+ β”‚ β”‚ ────────────────────► β”‚
1138
+ β”‚ β”‚ Book::newOrder()
1139
+ β”‚ β”‚ match β†’ Trade
1140
+ β”‚ β”‚ 35=8 ExecutionReport β”‚
1141
+ β”‚ β”‚ ◄──────────────────── β”‚
1142
+ β”‚ β”‚ update state, SSE β”‚
1143
+ β”‚ SSE: order, trade β”‚ β”‚
1144
+ β”‚ ◄───────────────── β”‚ β”‚
1145
+ ```
1146
+
1147
+ ### Connection Lifecycle
1148
+
1149
+ ```
1150
+ Toggle ON (β†’ C++) Toggle OFF (β†’ Python)
1151
+ ═══════════════════ ════════════════════════
1152
+ 1. TCP connect(:9001) 1. Send FIX Logout (35=5)
1153
+ 2. Send FIX Logon (35=A) 2. Close TCP socket
1154
+ 3. Start recv thread 3. Set mode = "python"
1155
+ 4. Set mode = "cpp" 4. Orders route to MatchingEngine
1156
+ 5. Orders route to bridge
1157
+ ```
1158
+
1159
+ ---
1160
+
1161
+ ## 18. Project Structure
1162
 
1163
  ```
1164
  EuNEx/
 
1201
  β”‚ β”œβ”€β”€ PersistenceStore.hpp Store interface
1202
  β”‚ └── KafkaStore.hpp Kafka adapter (optional, librdkafka)
1203
  β”‚
1204
+ β”œβ”€β”€ dashboard/
1205
+ β”‚ β”œβ”€β”€ app.py Flask dashboard + dual engine bridge
1206
+ β”‚ β”œβ”€β”€ database.py SQLite (orders, trades, OHLCV)
1207
+ β”‚ └── templates/index.html Trading UI with engine toggle
1208
+ οΏ½οΏ½οΏ½
1209
+ β”œβ”€β”€ clearing_house/
1210
+ β”‚ β”œβ”€β”€ app.py Flask CH portal + API
1211
+ β”‚ β”œβ”€β”€ ch_database.py SQLite (members, holdings)
1212
+ β”‚ β”œβ”€β”€ ch_ai_trader.py AI trading (momentum/mean_revert/random/llm)
1213
+ β”‚ └── templates/ CH web UI (leaderboard, portfolios)
1214
+ β”‚
1215
+ β”œβ”€β”€ fix_gateway/
1216
+ β”‚ └── fix_server.py Python FIX 4.4 TCP acceptor
1217
+ β”‚
1218
+ β”œβ”€β”€ shared/
1219
+ β”‚ └── config.py Centralized config (auto-loads .env)
1220
+ β”‚
1221
+ β”œβ”€β”€ .env LLM and service configuration
1222
+ β”‚
1223
  β”œβ”€β”€ tests/
1224
  β”‚ β”œβ”€β”€ test_orderbook.cpp Book unit tests (26 cases)
1225
  β”‚ β”œβ”€β”€ test_matching_engine.cpp ME integration tests
 
1239
 
1240
  ---
1241
 
1242
+ ## 19. Build & Test
1243
 
1244
  ### Prerequisites
1245
 
 
1298
 
1299
  ---
1300
 
1301
+ ## 20. Configuration
1302
 
1303
  ### Runtime Configuration (main.cpp)
1304
 
 
1327
 
1328
  ---
1329
 
1330
+ ## 21. Extending EuNEx
1331
 
1332
  ### Adding a New Symbol
1333
 
 
1362
  ### Future Roadmap
1363
 
1364
  ```
1365
+ Current (v0.9.5) Planned
1366
+ ════════════════ ═══════════════════════════════════
1367
 
1368
  βœ“ Limit + Market + Stop orders β–‘ Pegged, Mid-Point, Iceberg
1369
  βœ“ IOC, FOK, Day β–‘ GTD, GTC, VFU, VFCU
 
1376
  βœ“ Clearing house + AI traders β–‘ EuroCCP/LCH integration
1377
  βœ“ IACA fragments β–‘ IACA FINISH + COPY + IDS
1378
  βœ“ Python bridge (JSON) β–‘ SBE multicast MDG
1379
+ βœ“ Market simulation (C++ + Py) β–‘ Multi-day backtesting
1380
+ βœ“ Ticker tape + OHLCV charts β–‘ SATURN ARM (MiFID II RTS 22)
1381
+ βœ“ Daily close persistence β–‘ PTB (Post-Trade Box)
1382
+ βœ“ AI Analyst (Ollama/Groq/HF)
1383
+ βœ“ LLM trading strategy (CH)
1384
+ βœ“ Message Flow Visualizer
1385
+ βœ“ Engine mode switch (Py ↔ C++)
1386
+ βœ“ .env auto-loading config
 
1387
  ```
1388
 
1389
  ---
1390
 
1391
+ *Generated for EuNEx v0.9.5 β€” Euronext Optiq Architecture Simulator*