Skip to content
Back to Projects

2026

Exchange Lab: Market Simulator and Strategy Research Platform

  • C++20
  • Market Microstructure
  • Low-Latency Systems
  • Experimental Design
  • Statistics
  • GitHub Actions

Exchange Lab is a research and learning tool for market microstructure, driven from one terminal app. You write a trading strategy as a single C++ header, drop it into a simulated market that re-runs exactly, and find out where its money comes from and whether the result is real or noise. It is built for students learning how markets work and researchers who need controlled experiments, and it is deliberately not a backtester: the market is invented, so it explains why a strategy makes or loses money rather than whether to trade it.

Underneath is a price-time-priority exchange matching engine with self-trade prevention: a single-threaded core fed by a lock-free queue, with fixed-point prices and no memory allocation while trading. It matches 99.95% of orders in under 2 microseconds, and its replays are bit-identical from one machine to the next.

On top runs a seeded market of market makers, an informed trader, noise traders and momentum traders, who see the book only through the engine's event stream, as on a real venue. Every strategy is scored in the same seat, market and seeds as a do-nothing placebo, beside a zero-intelligence strategy that sets the floor it has to beat. Results are paired differences with standard errors and a multiple-testing correction, tuned on one block of seeds, confirmed once on a held-out block and checked against a fixed grid of changed conditions. A market that drifts loose from its true value is refused rather than scored.

It also reads market data you already have, from disk and never over a network: LOBSTER, Databento, Nasdaq ITCH, Tardis, Binance, Coinbase, Kraken or any CSV. The simulated market can be calibrated to resemble a file, behind a control whose answer is known in advance, or an order-by-order file can be replayed through the engine with one strategy trading in it.

Every run records its own conditions, and one command re-runs it and compares every output file byte for byte. Continuous integration builds it on Linux, Windows and macOS, on x86-64 and ARM64, and fails if any of their outputs differ. Version 1.0.0 is tagged under the Apache 2.0 licence, with eleven guided exercises that take a student from one order book to a strategy of their own.

Results & Highlights

  • Matches 99.95% of orders in under 2 microseconds, with no memory allocation while trading
  • Results identical byte for byte on Windows, Linux and macOS, on x86-64 and ARM64, checked by CI on every pull request
  • Scores strategies against a do-nothing placebo with paired statistics, a multiple-testing correction, held-out seeds and a sensitivity grid
  • Evaluator validated against known-answer controls and mutation-tested, so each control is proven to catch a planted bug
  • Imports eight market data formats, and calibrates the simulated market to a real file behind a known-answer check

Challenges

The market was built to ask what reaction speed is worth to a market maker, and the answer changed twice. The smallest delay tested was too small for the available seeds to resolve, so it was reported as underpowered rather than as no effect. A slower maker clearly lost money, but removing the informed trader left 96% of that loss, so the slow maker was losing order flow to its rival, not information to the informed trader. A second control, meant to create the effect on purpose, failed outright, and that failure is published too.

Calibrating the market to real data went wrong before it went right. Medians moved in whole ticks and gave the search nothing to steer by, so they were replaced by means. Two quite different markets, one with a wide spread and slow traders and one with a wider spread and fast traders, turned out to move at nearly the same pace, and a plain descent settled in the wrong one. A control with a known answer caught that, a coarse scan before the descent fixed most of it, and calibration now lists the other settings a file cannot tell apart instead of claiming one exact fit.

What I Learned

That how a plausible story gets tested and overturned matters more than any single number: controls with known answers, paired comparisons reported with their uncertainty, a held-out set touched once, and publishing the control that failed are what make a simulated result worth anything.