Orders with precise rules
Limit, market, stop, trailing-stop and iceberg orders. Choose GTC, IOC, FOK or GTD, with maker-only flags and optional self-trade prevention.
matching-enginev0.1.0
Rust · spot matching service
Match spot orders with price-time priority and eight-decimal fixed-point arithmetic. Connect over TCP or Unix sockets, persist decisions in a write-ahead log and recover orders and sessions after a restart.
Rust · MIT · Last update
Single-node service. Balances, settlement and failover are handled by your platform.
ASK #41 100.01 × 2
ASK #42 100.02 × 3
BUY #43 100.02 × 3
→ 2 @ 100.01 maker #41
→ 1 @ 100.02 maker #42
REST #42 100.02 × 2
matching-engine
Limit, market, stop, trailing-stop and iceberg orders. Choose GTC, IOC, FOK or GTD, with maker-only flags and optional self-trade prevention.
With WAL enabled, durable decisions, snapshots and retained session history support recovery and idempotent mutation retries.
Binary protocol v2, a Go client and examples in Go, Python, TypeScript and Rust. TLS/mTLS, Prometheus metrics and health/readiness endpoints.
Rust · spot matching service
Use Rust 1.96 or newer. Build the TLS-enabled server, then start it with config.toml. The sample binds trading to 127.0.0.1:9090 and HTTP to port 9091.
Check /ready, then run the Go example with a fresh data directory. Read the handbook for message framing, session replay and mutation request IDs.
Choose persistent storage and a fixed shard count. Configure TLS and risk limits; keep account balances, settlement and failover in your surrounding platform.
01 / Install
git clone https://github.com/rekurt/matching-engine.git && cd matching-engine &&
cargo build --release --locked -p me-server --features tls &&
./target/release/me-server --config config.toml02 / README
Rust spot matching service with price-time priority, fixed-point orders, WAL recovery and a binary TCP protocol.
Setup, examples and API reference.
A Rust service for matching spot orders with price-time priority. Each symbol is processed by one shard worker; clients connect through a binary protocol over TCP or Unix domain sockets.
Requires Rust 1.96 or newer. From the repository root:
cargo build --release --locked -p me-server --features tls
./target/release/me-server --config config.toml
The sample configuration listens on 127.0.0.1:9090 for trading and 127.0.0.1:9091 for HTTP, and stores journals under ./data/wal.
In another terminal:
curl --fail http://127.0.0.1:9091/ready
cd examples/go
go run . 127.0.0.1:9090
Use a fresh data directory for the example: order IDs and mutation request IDs are retained for recovery. For a remote deployment, configure TLS, a fixed shard count and persistent storage as described in the deployment guide.
This is a single-node matching service. Account balances, reserved funds, settlement, replication and failover belong to the surrounding platform. Session IDs are bearer credentials, not account identities. Journals and retained mutation history grow with activity; online compaction and legacy journal migration are not implemented. The example clients do not implement full settlement or reconnect recovery.
No latency SLA is implied. Measure the complete durable path on your own storage and workload; engine microbenchmarks exclude network and synchronous journal costs.
Project website · All projects by rekurt
The online handbook is built from docs/src:
Build the handbook with mdbook build; generate Rust API documentation with cargo doc --workspace --no-deps --all-features --locked.
MIT, copyright nikita42 (rekurt).
matching-engine