明确的订单规则
支持限价、市价、止损、追踪止损和冰山订单;提供 GTC、IOC、FOK、GTD、仅做市标记及可选的自成交预防。
matching-enginev0.1.0
Rust · 现货撮合服务
以价格时间优先规则和八位小数定点运算撮合现货订单。通过 TCP 或 Unix 套接字连接,将决策写入 WAL,并在重启后恢复订单和会话。
Rust · MIT · 最近更新
单节点服务。账户余额、结算及故障切换由你的平台负责。
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
支持限价、市价、止损、追踪止损和冰山订单;提供 GTC、IOC、FOK、GTD、仅做市标记及可选的自成交预防。
启用 WAL 后,持久化决策、快照与保留的会话历史支持状态恢复和幂等变更重试。
二进制协议 v2、Go 客户端及 Go、Python、TypeScript、Rust 示例。提供 TLS/mTLS、Prometheus 指标与健康、就绪端点。
Rust · 现货撮合服务
需要 Rust 1.96 或更高版本。构建启用 TLS 的服务,再用 config.toml 启动。示例交易端口为 127.0.0.1:9090,HTTP 端口为 9091。
检查 /ready,使用新的数据目录运行 Go 示例。消息格式、会话重放与变更请求 ID 见英文手册。
选择持久存储与固定分片数,配置 TLS 和风险限额。账户余额、结算及故障切换由外围平台实现。
01 / 安装
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 现货撮合服务,支持价格时间优先、定点订单、WAL 恢复与二进制 TCP 协议。
配置说明、使用示例和 API 参考。
以下为仓库的原始文档,未作翻译;上方的示例与入门说明已本地化。
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