- Stack
- C++20 · CMake · GoogleTest · GitHub Actions
Problem
An order book has to stay exactly right under every sequence of adds, cancels, modifies and partial fills. Floating-point price comparisons and untested edge cases are where books go wrong.
Approach
- Price-time priority book supporting add, cancel, modify and partial fill.
- Queries for best bid and ask, spread, mid, depth and price-level snapshots.
- A seeded, deterministic, Poisson-timed synthetic order generator for stress tests and benchmarks.
Key decisions
- Prices are integer ticks, which rules out floating-point equality bugs.
- The order generator is seeded and deterministic, so any failing run can be replayed exactly.
Evidence
- 32 GoogleTest cases, including a 5,000-event randomised stress test.
- CI matrix with a plain build and an ASan + UBSan sanitizer build.
What's next
- Planned: a matching engine with pre-trade risk controls.
- Planned: deterministic replay of real market data.
- Planned: benchmarked tick-to-trade latency at P50, P99 and P99.9.