How programmeradi-369/low-latency-order-matching-engine works
This C++ order-matching engine accepts limit and market orders, validates their IDs and quantities, matches incoming orders by price-time priority, and retains unfilled limit orders in the book. Its executable demonstrates cancellation, partial and cascading fills, then reports latency and throughput; trade records can also be exported as CSV. The graph follows the documented API and sampled calls. TradeLogger implementation was not sampled, so its internal storage and CSV-writing details are represented only at the documented interface level.
Main entry points: main.cpp Scenario runner · MatchingEngine.cpp Matching engine · TradeLogger.h Trade logger · OrderManager.cpp Order validation
Components 10
Runtime orchestration
- Scenario runner
src/main.cpp - Order validation
src/OrderManager.cpp - Order model
include/Order.h
Order matching
- Matching engine
src/MatchingEngine.cpp - Price-level book
src/OrderBook.cpp
Trade and metrics
- Trade record
include/Trade.h - Trade logger
include/TradeLogger.h - CSV export
trades.csv - Performance analytics
src/PerformanceAnalyzer.cpp
Other components
- Operator
Connections 12
- Operator → Scenario runner: runs scenarios
- Scenario runner → Order validation: creates orders
- Order validation → Order model: constructs
- Scenario runner → Matching engine: submits orders
- Matching engine → Price-level book: reads and updates
- Matching engine → Trade logger: records trades
- Matching engine → Trade record: creates records
- Scenario runner → Matching engine: cancels orders
- Scenario runner → Price-level book: prints book
- Scenario runner → Trade logger: prints and exports
- Trade logger → CSV export: exports CSV
- Scenario runner → Performance analytics: records latency