rust-order-book

Crates.iorust-order-book
lib.rsrust-order-book
version0.0.2
created_at2025-08-29 08:22:51.962428+00
updated_at2025-08-29 19:00:27.145431+00
descriptionA Rust Lmit Order Book for high-frequency trading (HFT).
homepagehttps://github.com/fasenderos/rust-order-book
repositoryhttps://github.com/fasenderos/rust-order-book
max_upload_size
id1815528
size149,125
Andrea Fassina (fasenderos)

documentation

https://docs.rs/rust-order-book

README

Rust Order Book β€” High-performance Limit Order Book in Rust

Crate Badge Repo Badge Docs Badge License Badge
CI Badge Deps Badge Codecov Badge

Ultra-fast Rust Limit Order Book
for high-frequency trading (HFT) :rocket::rocket:

:star: Star me on GitHub β€” it motivates me a lot!

This crate is a Rust port of one of my Node.js projects, the nodejs-order-book.
It works, but don't be surprised if it's not 100% idiomatic yetβ€”or if some features (like conditional orders) are still missing.
They will be added over time. βœ…

Table of Contents


Features

  • πŸš€ Ultra-fast (no unsafe) implementation in pure Rust
  • πŸ“ˆ Suitable for HFT and exchange backtesting
  • βœ… Standard price-time priority
  • 🏦 Market and limit orders
  • πŸ”’ post-only support
  • ⏳ Time in force: GTC, IOC, FOK
  • πŸ”„ Modify & cancel orders
  • πŸ§ͺ Tested with benchmarks and coverage

Installation

Run the following Cargo command in your project directory:

cargo add rust-order-book

Or add the following line to your Cargo.toml:

[dependencies]
rust-order-book = "0.0.1"

Usage

use rust_order_book::{LimitOrderOptions, MarketOrderOptions, OrderBookBuilder, Side};

let mut book = OrderBookBuilder::new("BTCUSD").build();

let _ = book.limit(LimitOrderOptions {
  side: Side::Buy,
  quantity: 100,
  price: 50,
  time_in_force: None,
  post_only: None,
});

let _ = book.market(MarketOrderOptions {
  side: Side::Sell,
  quantity: 50,
});

let _ = book.modify(1, 60, None);

let _ = book.cancel(1);

Example Output

You can easily inspect the state of the book:

println!("{}", book);

Example:

1200 -> 10
1100 -> 5
------------------------------------
900 -> 15
850 -> 5

Development

Testing

cargo test

Coverage

cargo llvm-cov

Benchmarking

cargo bench

Contributing

I would greatly appreciate any contributions to make this project better. Please make sure to follow the below guidelines before getting your hands dirty.

  1. Fork the repository
  2. Create your branch (git checkout -b my-branch)
  3. Commit any changes to your branch
  4. Push your changes to your remote branch
  5. Open a pull request

Donation

If this project help you reduce time to develop, buy me a coffee 🍡😊
  • USDT (TRC20): TXArNxsq2Ee8Jvsk45PudVio52Joiq1yEe
  • BTC: 1GYDVSAQNgG7MFhV5bk15XJy3qoE4NFenp
  • BTC (BEP20): 0xf673ee099be8129ec05e2f549d96ebea24ac5d97
  • ETH (ERC20): 0xf673ee099be8129ec05e2f549d96ebea24ac5d97
  • BNB (BEP20): 0xf673ee099be8129ec05e2f549d96ebea24ac5d97

License

Copyright Andrea Fassina, Licensed under MIT.

Commit count: 18

cargo fmt