Low-latency limit order book and matching engine. C++20 over Boost.Intrusive, designed for sub-microsecond order processing on Linux x86_64.
- Strict price-time priority FIFO matching at every level.
- Dense tick-ladder order book with hierarchical bitmap for
O(1)best-bid / best-ask lookup. - Time-in-force coverage: GTC, IOC, FOK. Post-only and pegged on the roadmap.
- Configurable self-cross policy: cancel-newest, cancel-oldest, decrement-trade.
- Slab arena over preallocated, cache-aligned storage; intrusive freelist
removes runtime
new/deletefrom the hot path. boost::intrusive::listFIFOs at each price level; no node allocation per order.- Open-addressed robin-hood map (
ankerl::unordered_dense::segmented_map) for order-id to order lookup on cancel and modify. - 2 MiB huge-page backing for the slab arena where the host allows, cutting data-TLB pressure during bursts, with a transparent fallback to regular pages and no change to the first-touch NUMA policy.
- Single-threaded engine pinned to an isolated core.
- Vyukov-style bounded SPSC ring at the ingress and egress boundaries, cache-line padded heads and tails, no false sharing.
- Multi-symbol scalability via per-symbol shard router over independent per-symbol engines.
- Threaded shard runtime that drives each shard on its own worker thread, pinned to its own core, draining a dedicated SPSC ingress ring.
- Optional per-shard egress rings so each shard publishes events into its own SPSC ring, keeping the publish path lock-free and contention-free.
- Single-threaded merging consumer that fans the per-shard egress rings into one sequenced event stream for a downstream recorder or publisher.
- Publisher-concept seam bridging the merged stream onto any publisher, so the runtime streams straight into the JSON Lines recorder unchanged.
- Zero-copy FIX 4.4 tag-value parser over
std::span<const std::byte>, no allocations, nostd::string. Tracked under a separate ADR.
- Monotonic sequence number on every command and event; replay from any prefix reproduces engine state bit-exactly.
- Snapshot sink serialises the book to a flat POD layout for warm-start.
- Latency histograms via
nanobenchfor tail-aware p50 / p99 / p99.9. - In-process HDR latency histogram (
lob::latency_histogram) with O(1) allocation-free record and exact percentile queries for the engine's own timing loops. scripts/perfstat.shwrapsperf statfor IPC, branch-miss and L1-miss telemetry under a fixed-seed workload.- CI bench job gates throughput regressions against
bench/baseline.json.
Requires CMake 3.28, vcpkg in manifest mode, and a C++20 compiler (GCC 13+, Clang 17+, Apple Clang 15+).
git clone https://github.com/ZacKienzle2/Orderbooks
cd Orderbooks
cmake --preset linux-clang-rel
cmake --build --preset linux-clang-rel
ctest --preset linux-clang-rel --output-on-failuremacOS dev:
cmake --preset macos-clang-dev
cmake --build --preset macos-clang-dev
ctest --preset macos-clang-dev --output-on-failureBenchmarks:
cmake --build --preset linux-clang-rel --target lob_bench
./build/linux-clang-rel/bench/lob_bench --benchmark_format=json | tee bench/last.jsonA .venv exists for repo tooling only: pre-commit, clang-format,
cmake-format, ruff, pytest for harness scripts, pandas and
matplotlib for latency analysis. It is not a runtime dependency.
uv sync --frozen
uv run pre-commit install --install-hooksinclude/lob/ public headers (header-only domain types + engine ABI)
src/lob/ translation units (build-only internals)
tests/ Catch2 v3 unit + property tests, reference engine, replay fixtures
bench/ Google Benchmark microbenches + nanobench tail reports
cmake/ warnings, sanitisers, hardening, dependencies modules
scripts/ perfstat, formatting, lint, replay helpers
docs/ design specs, dev guides, ADRs
See CODEOWNERS.
See CONTRIBUTING.md. Conventional Commits 1.0.0 and DCO sign-off required.
MIT.
SECURITY | SUPPORT | GOVERNANCE | CHANGELOG | ROADMAP | CITATION