case · 006
Cross-exchange orderbook aggregator.
A lightweight, dependency-light service that maintains a live orderbook per exchange (Binance, Coinbase, Kraken, Bitstamp) via WebSocket, then merges them into a unified book for BTC, ETH, and SOL across USDT pairs. Exchanges that send snapshots via REST (Binance, Bitstamp) buffer WebSocket deltas until the snapshot lands, then replay in order.
fig. 0.1
Cover image · orderbook aggregation diagram
Trading on one exchange and watching another for arbitrage means juggling four browser tabs, four API keys, and four rate-limit budgets — and missing the prints that matter in the gaps.
Our team built the aggregation service as a single Bun binary with no external runtime dependencies. The 13KB browser bundle runs the same aggregation client-side too — open `docs/index.html` and the books connect directly to exchanges from your browser, no server required.
exchanges (Binance, Coinbase, Kraken, Bitstamp)
coins × USDT pairs (BTC, ETH, SOL)
browser bundle, zero dependencies
merged ladder across all four venues
Per-exchange normalisation is the hard part: each venue sends a different message shape, ordering, and update semantics. We subscribe to L2 orderbook channels, normalise into a common `BookChange` format, then merge by summing amounts at matching price levels.
Exchanges that send snapshots via REST (Binance, Bitstamp) buffer WebSocket deltas until the snapshot arrives, then replay the buffered diffs in order so the merged book stays internally consistent. The merged book holds L2 depth across all four venues, and the depth-of-N call (N configurable per request) returns the same merged view regardless of which venue matched.
/ stack
- n/a — read-side aggregation only (no on-chain transactions)
- Bun runtime
- TypeScript
- native WebSocket
- REST snapshot replay
- zero external dependencies
next case study
Quantitative trading research platform..
A research-and-signal platform built for serious traders: a Next.js 15 dark-themed dashboard (TanStack Query, Recharts for financial charts, Zustand for client state) over a FastAPI backend with versioned Alembic migrations on SQLite → PostgreSQL. Phased delivery: data ingestion → signal engine → backtester → AI-assisted scoring.
/ start a project