Skip to content
AS
All projectsPersonal project

Exchange

A stock exchange that runs in your browser

A working stock exchange, options pricer and risk lab with a C++ engine compiled to WebAssembly.

Role
Solo project
Category
Trading Systems
Status
Complete
Stack
C++20, WebAssembly, Next.js, React, TypeScript, Web Workers, WebSockets
Exchange preview

(01) What it is

The project

I wanted to understand how an exchange actually works, so I built one. The core is a C++20 matching engine with price time priority, plus a small quant library. Both compile to WebAssembly and run in Web Workers behind a React frontend, so the whole thing runs in the browser with no server.

You can trade against simulated market makers, price options, play with volatility surfaces, stress test a portfolio and backtest strategies. There's also a live mode that streams real Bitcoin, Ether and Solana order books from Coinbase and Kraken and lets you paper trade against them.

(02) Details

How it works

  1. 01Supports limit, market, IOC, FOK, post only and stop orders, plus self trade prevention
  2. 02Sessions are event sourced, and replaying the log gives the same 64 bit state hash in both the native and WebAssembly builds
  3. 03Options pricing with Black Scholes, Greeks, implied volatility, binomial trees and Monte Carlo
  4. 04Live order books come in over WebSockets and get parsed off the main thread
  5. 0577 GoogleTest cases (also run under AddressSanitizer and UBSan), 55 Vitest tests and 34 Playwright tests

(03) Screenshots

Placing orders against the C++ order book
Placing orders against the C++ order book
A live Bitcoin order book from Coinbase
A live Bitcoin order book from Coinbase
Next projectSpectra