← Back to selected work

01 / Systems & simulation

A market,
from the inside.

Every trade starts with someone willing to buy and someone willing to sell. What happens between those two intentions?

C++17Python bindingsMarket microstructure

Start with one order.

The book holds orders waiting to trade. Buyers sit on one side, sellers on the other. The gap between the highest bid and the lowest ask is the spread.

Try buying 12 units. Only 10 are available at the best ask, so the remaining two trade at the next price. Reset the book and try a limit order to choose the most you’re willing to pay.

Explore the source ↗
A small experiment. Go ahead, trade.
Interactive snapshot
The order book / XYZ
SANDBOX
Mid $100.00Spread $0.04
Bid / $Qty
99.9818
99.9626
99.9434
99.9242
99.9050
Ask / $Qty
100.0210
100.0415
100.0622
100.0832
100.1045
Simulated market · browser adaptationInside the project ↗

What’s underneath a price chart?

LOBSimulater is an order-book engine and event-driven backtesting framework. The project explores the mechanics that a price chart hides: queue position, available depth, individual fills, and the signals that can be extracted from order flow.

The C++ engine supports aggregated and individual-order views, with a Python binding for analysis and experimentation.

Price first. Then arrival time.

Orders are organized into price levels. Within each level, a linked queue preserves arrival order. This separates two questions: which price should trade first, and which order at that price has priority?

  • The book: manages price levels, quantities, order updates, and cancellation.
  • The backtester: processes events and tracks fills, positions, cash, and performance.
  • The research layer: derives signals such as imbalance, microprice, and queue position.
  • The Python bridge: exposes the C++ classes through pybind11.

A faster engine is only useful if its behavior remains understandable. The repository includes order-book tests, backtester tests, and a throughput benchmark.

A small model you can take apart.

The interactive book above is an educational JavaScript adaptation, using synthetic orders. It matches by price and arrival time, handles partial fills, and leaves unfilled limit orders in the queue. Unfilled market orders are discarded.

It displays the best five price levels on each side. There are no fees, latency, hidden liquidity, or live market data. It illustrates the mechanics; it does not execute the C++ engine or measure its performance.

Read the browser model ↗Explore the C++ tests ↗

Keep exploring

Make every guess count.

Always up for a good conversation

Have something
on your mind?

yohanze@icloud.com