explaingit

darthchudi/lob

Analysis updated 2026-06-24

0RustAudience · researcherComplexity · 3/5Setup · easy

TLDR

Rust research library for a price-time-priority limit order book, with a pluggable matching strategy enum, fill output, depth snapshots, and criterion benchmarks.

Mindmap

mindmap
  root((lob))
    Inputs
      Buy orders
      Sell orders
      Tick calls
    Outputs
      Fills list
      Depth snapshot JSON
      Bench numbers
    Use Cases
      Test matching algorithms
      Backtest strategies
      Build RL trading env
      Replay order flow
    Tech Stack
      Rust
      rust_decimal
      Criterion
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Backtest a trading strategy against a deterministic order book

USE CASE 2

Train a reinforcement learning agent in a custom matching environment

USE CASE 3

Replay historical order flow and inspect resulting fills

What is it built with?

Rustrust_decimalCriterion

How does it compare?

darthchudi/lobbakome-hub/bakome-crypto-quant-engineearonesty/edge-tls-ws-bridge
Stars000
LanguageRustRustRust
Setup difficultyeasyeasymoderate
Complexity3/53/54/5
Audienceresearcherdeveloperops devops

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Plain cargo project, cargo run --example simple_order_flow gives an immediate working demo.

In plain English

lob is a small Rust library that implements a limit order book, the data structure at the heart of every stock exchange or crypto matching system. Bids, the prices buyers are willing to pay, and asks, the prices sellers are willing to accept, are stored sorted by price, and when a buy and a sell cross at the same price the book matches them and produces a fill. The author positions the project as a research tool for experimenting with order matching behaviour and order flow, rather than a production exchange. The default matching rule is price time priority. Orders are sorted first by best price, then within a price level by who arrived first, using a FIFO queue per level. The code is laid out so that the matching engine is a separable component behind a strategy enum, with the current execution layer wired to the price time priority plan. Listed use cases include testing different matching algorithms, building reinforcement learning environments, backtesting trading strategies, building custom books, and replaying historical order flow. Usage looks like creating a LimitOrderBook with the PriceTimePriority strategy, adding buy and sell orders built from the utils helpers with rust_decimal amounts, then calling tick to match the book and read back a list of fills. Two example programs come with the repository. simple_order_flow adds synthetic orders and ticks the book, and depth_snapshot exports the market depth as JSON for plotting in any chart tool. Both are launched through cargo run --example. Benchmarks live in the benches directory and run with cargo bench, using the criterion crate. The current numbers reported in the README are a median 30.866 milliseconds to build a fresh book and insert 10,000 resting orders, which works out to about 323,990 input orders per second, and a median 480.75 milliseconds to fully match and drain a crossed book of 2,000 input orders, about 4,160 input orders per second. The author is candid about current limits. Only limit orders are supported, so market orders, stop losses, and similar types are not yet there. The execution engine assumes the price time priority plan, so plugging in a very different algorithm needs execution layer changes too. Calculating volume at a price level walks the whole queue at that level, and cancellation within a level is also a linear scan.

Copy-paste prompts

Prompt 1
Walk me through creating a LimitOrderBook, adding crossing orders, and printing the fills
Prompt 2
Run cargo run --example depth_snapshot and explain the JSON it writes
Prompt 3
Add a market order type to the matching engine without breaking price time priority
Prompt 4
Replace the linear cancel scan inside a price level with a doubly linked list lookup

Frequently asked questions

What is lob?

Rust research library for a price-time-priority limit order book, with a pluggable matching strategy enum, fill output, depth snapshots, and criterion benchmarks.

What language is lob written in?

Mainly Rust. The stack also includes Rust, rust_decimal, Criterion.

How hard is lob to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is lob for?

Mainly researcher.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.