An ongoing, from-scratch C++ project exploring low-latency trading infrastructure.
The current implementation centers on a limit order book and matching engine, with ongoing expansion into other aspects of trading infrastructure. The long-term goal is to build an end-to-end simulated trading system.
- Basic price-time priority matching
- Order IDs and cancellation
- Partial fills and timestamps
- Correctness tests
- Memory allocation profiling and optimization
- Single-threaded matching engine
- Mutex + condition variable implementation
- Lock-free SPSC ring buffer implementation
- Concurrency benchmarks
- Queue-only benchmarking and capacity analysis
- Additional trade-output benchmarking
- State persistence and recovery
- Order and trade event publication
- Market-data simulator
- Feed handler
- SPSC event pipeline
- Market-state reconstruction
- Strategy
- Risk engine
- Order management system (OMS)
- Exchange simulator
The long-term goal is an end-to-end simulated trading system, covering market-data ingestion, strategy execution, order management, and exchange simulation.
MARKET DATA
|
v
+-----------------------+
| Market Data Simulator |
+-----------+-----------+
|
v
+-----------------------+
| Feed Handler |
+-----------+-----------+
|
v
+-----------------------+
| SPSC Ring Buffer |
+-----------+-----------+
|
v
+-----------------------+
| Market State / Book |
+-----------+-----------+
|
v
+-----------------------+
| Strategy |
+-----------+-----------+
|
v
+-----------------------+
| Risk Engine |
+-----------+-----------+
|
v
+-----------------------+
| OMS |
+-----------+-----------+
|
v
+-----------------------+
| Exchange Simulator |
| |
| Matching Engine |
| | |
| v |
| Limit Order Book |
+-----------+-----------+
|
v
Execution Reports
The target architecture is a conceptual design. Components will be implemented incrementally.
The existing implementation focuses on the order-matching subsystem, supporting two alternative concurrency mechanisms.
Producer
|
v
+-------------------------+
| Order Submission |
+------------+------------+
|
v
+-------------------------+
| Transport Variant |
| |
| Mutex + Condition Var. |
| OR |
| SPSC Ring Buffer |
+------------+------------+
|
v
+-------------------------+
| Matching Engine |
| (Single Consumer) |
+------------+------------+
|
v
+-------------------------+
| Limit Order Book |
| |
| Match / Rest / Cancel |
+-------------------------+
Both concurrency variants share the underlying order-book implementation, allowing their performance to be compared under equivalent workloads.
The project follows a simple unity-build approach, compiling each executable from a single entry-point translation unit.
No CMake or Makefiles are required.
./build.sh
./build/mainEach test entry point is compiled into a standalone executable.
./build.sh tests/limit_order_book_test.cpp
./build/limit_order_book_test
./build.sh tests/spsc_queue_test.cpp
./build/spsc_queue_testBenchmarks are maintained separately from the main program and correctness tests.
./build.sh benchmark/<benchmark_name>.cpp
./build/<benchmark_name>Performance measurements should use optimized builds (e.g. -O3) rather than debug builds (-O0).
MIT License