AsthaMishra/matching-engine
From-scratch limit order book + matching engine in Rust. ~100 ns book ops replaying 104M operations from real NASDAQ ITCH 5.0 data; 143-fill sweeps in 2 µs. Binary OUCH order entry, 10 µs order-to-ack.
⚡ Rust matching engine with real NASDAQ ITCH replay
From-scratch limit order book in Rust: ~100 ns book ops, 143-fill sweeps in 2 µs, OUCH order-to-ack in 10 µs on loopback.
AsthaMishra's matching-engine is a limit order book and matching engine written in Rust to learn low-latency systems design from first principles. It ships with a NASDAQ OUCH/ITCH-style binary gateway and was validated by replaying 104.6M operations from real NASDAQ ITCH 5.0 data.
✨ Highlights
- Layered crates:
matching-core(pure engine, no threads or I/O),matching-engine(sharded workers),ouch-gateway(binary protocol),rest-gateway(Axum queries),server(wiring). - Sharded threading: each symbol's book is single-threaded with one owner; symbols spread across a fixed worker pool by
symbol_id % num_workers— not thread-per-symbol. - Book ops: 51 ns top-of-book match, 58 ns cancel at depth-1000, 0.90 ns BBO, ~30M warm inserts/s.
- ITCH replay: p50 99 ns, p99 502 ns, ~5.9M ops/s over 104.6M ops from a real trading day.
- Sweeps: 143-fill marketable sweep in 2.0 µs (~14 ns/fill).
- Order-to-ack: p50 10.4 µs, p99 19.6 µs, pipelined 2.0M orders/s over loopback, OUCH codec + TCP included.
- Honest numbers: every figure states what it measures; microbenchmarks exclude network, order-to-ack is reported separately in microseconds.
- Tested: unit + property tests (proptest), Criterion benches, cargo-fuzz, hdrhistogram.
💡 Why it matters
Most repo benchmarks mix scopes and inflate claims. This one separates book ops, ITCH replay, matching path and end-to-end order-to-ack, and states the caveats plainly: loopback only, closed-loop load generator, WSL2 scheduler noise. Useful as a reference for lock-free routing, response slot pools and sharded book ownership.
Not a claim of HFT-grade wire latency — the point is the data-structure and systems work.
#Rust #MatchingEngine #LowLatency #HFT #TiniX
Similar Projects
Discover other similar projects and AI models.
High performance components for building Trading Platform such as ultra fast matching engine, order book processor
Ultra-fast Limit Order Book for Node.js written in TypeScript for high-frequency trading (HFT) :rocket::rocket:
Thousands of symbols based on K8S fleet. Raft-replicated order-book matching engine in Rust — Durable by consensus, Adapting to Equity/ForEx/Crypto/Derivatives with fee deduction, Deterministic from order intake to market data, Operational console, Lightening fast, Production quality, Nice WebUI, Comprehensive Documentation
Ultra-fast matching engine written in Java based on LMAX Disruptor, Eclipse Collections, Real Logic Agrona, OpenHFT, LZ4 Java, and Adaptive Radix Trees.
Low latency Limit Order Book and Matching Engine created in C++, able to handle over 1.4 million transactions per second.
simple, fast and feature rich order matching engine supports limit, market, stop-loss, iceberg, IOC, FOK, GTD orders
Exchange-grade CLOB matching engine + microstructure analytics in C++20
High-Frequency Trading (HFT) order matching engine optimized for low latency. Features NUMA-aware memory allocation, thread pinning, RDTSC timestamps, lock-free SPSC queues, async logging, and UDP busy polling. Built with C++20 for Linux production environments.