A real-time service that reconstructs live order books from crypto-exchange feeds, normalizes them into one canonical stream, and fans that stream out to consumers — with correctness properties that hold under reconnects, sequence gaps, and slow consumers. Binance and Kraken are wired live today (see Status); another venue would be an adapter behind the transport port.
Anyone building on market data needs one reliable, normalized view of it. Each venue speaks a different WebSocket protocol, sequences updates differently, and disconnects without warning. The valuable part is not a trading strategy — it's the data layer underneath it.
The hardest piece of that layer is the order book. An exchange sends a snapshot and then a stream of incremental deltas; you reconstruct the book yourself. Apply a delta across a sequence gap, or mishandle the snapshot-vs-stream race, and the book silently goes wrong: it crosses (bid at or above ask), or drifts from reality with no error raised.
- Ingests a live order-book feed over WebSocket (Binance and Kraken today; a further venue is an adapter behind the transport port, plus any engine option its feed needs).
- Reconstructs the venue's L2 order book from snapshot plus incremental deltas, detecting sequence gaps and resynchronizing from a fresh snapshot when one is found.
- Normalizes the venue's heterogeneous format into a single canonical book model. A
Tradetype is defined, but no adapter produces trades. - Fans the normalized stream out to consumers with backpressure handling.
Checked continuously, not assumed:
- The book never crosses. The best bid is always strictly below the best ask. A delta that would cross is rejected and counted, the book resyncs, and a crossed view is never stored for readers.
- The book stays in sync with the venue. Where a venue numbers updates, a missing number is a gap; where it publishes a checksum instead, a mismatch is the equivalent signal. Either way the book doesn't guess — it resynchronizes from a new snapshot, following each exchange's documented recovery procedure.
Enforced by a seeded deterministic simulation: it drives the engine over many runs with injected gaps, reorders, duplicates, disconnects and crossing updates, and checks that no view sampled after any step crosses and that the final top-N view matches an independent truth book. Recovery procedure per venue and the exact failure model are in docs/correctness.md.
Generated by tools/figuregen, which runs the engine and captures what it actually does, rather than
illustrating it after the fact. Figure 1 and the social card are deterministic (a seeded synthetic source) and a test fails if the committed
SVG differs from what the command produces. Figures 2 and 3 are captures from the live Kraken feed: they are not
reproducible byte for byte. Figure 2 states when it was taken; Figure 3's raw samples are not stored yet (see ADR-0025).
The reconstruction and fan-out logic is written against an abstract transport, with no knowledge of sockets or any specific exchange. Live connections exist only at the edge, as adapters implementing that transport — so the correctness story is tested deterministically, against a seeded synthetic feed where every gap, reorder, and disconnect can be reproduced exactly.
exchanges (live) tickerplant consumers
┌──────────────────┐ ┌────────────────────────┐
│ venue A (WS) │─────►│ ingestion adapters │
├──────────────────┤ │ (transport port) │
│ venue B (WS) │─────►│ │ │
├──────────────────┤ │ canonical model │
│ synthetic source │─────►│ │ │
│ (tests, same │ │ order-book engine │
│ port) │ │ (invariant-checked) │
└──────────────────┘ │ │ │ ┌────────────────┐
│ fan-out (in-process) │─────►│HTTP edge (SSE) │
└────────────────────────┘ ├────────────────┤
│dashboard (web) │
└────────────────┘
One process runs a single source (the diagram shows every source the port accepts, not what runs at
once): the synthetic one, or one live venue chosen with -live -venue binance|kraken.
The fan-out is a small in-process broadcaster: the engine stores a complete, immutable top-N view (depth 10 by default), the run loop hands it to the fan-out, and each consumer holds a size-1 latest slot. A lagging consumer jumps to the freshest book rather than replaying stale ones, and past a bound a consumer that can't keep up is disconnected.
Each venue's book has exactly one writer goroutine; readers get a consistent view through an atomically published snapshot, so reads take no lock on the writer's hot path. The reasoning, and the alternative it was weighed against (a reader-writer lock on the hot update path), is ADR-0008 in docs/decisions.md — 22 decisions in total.
Narrow and deep on purpose: two venues, reconstructed correctly (Binance and Kraken), with a further venue an adapter rather than a rewrite.
Out of scope: trading and execution (this is the data layer, not a bot); arbitrage capture, colocation, and MEV infrastructure (capital-intensive and a different problem); crash persistence (state lives in memory — correctness covers reconnects and gaps for a live process, not surviving a crash).
The engine measures internal processing latency — raw frame off the adapter's frame channel to the applied view stored for readers — as a measured distribution (p50/p99/p99.9/max). Figure 3 above is a live 5-minute capture: 83.7% of updates were within the 1µs resolution floor, and the percentiles shown are of the remaining 16.3% (these numbers come from a capture whose raw samples were not kept; a stored capture will replace them). End-to-end latency from the exchange is network round-trip, which this system doesn't control.
The open-loop benchmark in bench/ is published as one stated run, below, copied from the committed log
(bench/results/2026-10-23-i7-10870h-linux-vm.txt) by a test that fails if the two differ. Read it with its limits:
- Where it ran. A Linux container under Docker Desktop (a WSL2 virtual machine) on a Windows 11 laptop with an Intel i7-10870H, in ordinary use, not bare metal. Other hardware will differ, and so does another run on the same laptop: the log holds ten runs, and the min and max columns show the spread.
- Why Linux. On the same laptop under Windows the clock advances in steps of about half a millisecond or more (the benchmarks measure the step when they start and refuse to run when it is too coarse for the interval), which cannot hold or measure a schedule of 50 µs. The engine's own latency histogram reads the same clock, so on Windows small spans are quantised to zero or one step.
- What the two benchmarks send.
svcis the synthetic pipeline at 20,000 events a second.due,engineandpublishcome from generated BinancedepthUpdateframes (synthetic, 8 levels per side, a book of about 300 levels) sent at 5,000 frames a second through the real adapter. Both rates are stress rates: Binance's depth streams update every 100 ms or 1000 ms, and this system subscribes to the 1000 ms one. - The three spans.
engineis the span the system reports (frame off the adapter's channel to the view stored).dueruns from when a frame was due to whenPublishreturned, so it also holds the scheduler's wake-up of a parked goroutine and the channel hand-off. By subtraction (the median ofdueless the medians ofengineandpublish) about 115 µs of the 155 µs median lies outside the measured spans; that is attributed to the wake-up and hand-off in this virtual machine, but it was not measured separately.publishis the time aroundhub.Publish, which includes signalling the consumer: sub-microsecond in the synthetic run and about 18 µs in the wire run; the cause of the difference was not measured (a consumer that has to be woken is a guess). - Statistic. The median of ten per-run values, each from 100,000 events after a 2,000-event warmup; min and max
are across the ten runs. Quantiles are histogram estimates with 2% bucket resolution; a
maxis the worst single event of its run. The tail includes garbage-collection pauses (3 cycles a run,gc-cyclesinbench/README.md) and ordinary scheduler preemption of the spinning pacer.
Run facts, from the header of the log:
| go-version | go1.26.10 |
| goos-goarch | linux/amd64 |
| cpu | Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz |
| logical-cpus | 16 |
| clock-tick-ns | 100 |
| date | 2026-10-23T04:38:23Z |
| commit | 4a5f01f8c4f3f21b04756e6d0b15cf6ecb9fe3e6 |
| note | Linux container (golang:1.26.10-alpine) under Docker Desktop, a WSL2 virtual machine, on a Windows 11 laptop in ordinary use; not bare metal; no attempt was made to quiet the machine |
BenchmarkPipelineLatency (-cpu 4, 10 runs; median, then min and max across the runs)
| metric | median | min | max |
|---|---|---|---|
| publish-p50-ns | 399 ns | 302 ns | 399 ns |
| publish-p99-ns | 26.4 µs | 19.4 µs | 35.1 µs |
| samples | 100000 | 100000 | 100000 |
| sender-late | 271.5 | 75 | 946 |
| svc-max-ns | 677 µs | 236 µs | 7.33 ms |
| svc-p50-ns | 2.17 µs | 1.91 µs | 2.73 µs |
| svc-p99-ns | 36.2 µs | 24.6 µs | 76 µs |
| svc-p999-ns | 157 µs | 63.6 µs | 2.53 ms |
BenchmarkWireLatency (-cpu 4, 10 runs; median, then min and max across the runs)
| metric | median | min | max |
|---|---|---|---|
| due-max-ns | 9.96 ms | 4.69 ms | 14.8 ms |
| due-p50-ns | 155 µs | 152 µs | 164 µs |
| due-p99-ns | 295 µs | 249 µs | 349 µs |
| due-p999-ns | 2.34 ms | 573 µs | 8.8 ms |
| engine-max-ns | 1.17 ms | 283 µs | 10.2 ms |
| engine-mean-ns | 24.5 µs | 23.4 µs | 28.3 µs |
| engine-p50-ns | 22 µs | 20.6 µs | 25.1 µs |
| engine-p99-ns | 57.6 µs | 53.2 µs | 85.5 µs |
| engine-p999-ns | 103 µs | 90.8 µs | 171 µs |
| publish-p50-ns | 17.7 µs | 17.2 µs | 19 µs |
| publish-p99-ns | 30.2 µs | 26.6 µs | 39.5 µs |
| samples | 100000 | 100000 | 100000 |
| sender-late | 159 | 29 | 623 |
| util-pct | 19.8 % | 18.9 % | 22.1 % |
Method, the full table and how to reproduce: bench/README.md.
Go, standard library only for the core (model, transport port, engine, fan-out) — one third-party WebSocket client at the edge (ADR-0014). A Next.js/TypeScript dashboard on top. GitHub Actions runs CI.
docker compose up --build
Brings up the edge (:8080) and the dashboard (:3000) together. No account or API key required —
the edge defaults to the deterministic synthetic source. Open http://localhost:3000.
To watch the book heal itself, add -chaos to the edge command in docker-compose.yml: the synthetic source then
injects a gap, a reorder, a duplicate, a disconnect, a crossing delta and a coalesced delta in every 300 steps, on a
schedule fixed by -seed. The recoveries show in /api/status and /metrics (gaps, resyncs, disconnects,
would-crosses) and in the stream's telemetry. -chaos cannot be combined with -live.
For live data instead:
docker compose run --rm --service-ports edge -http :8080 -live -venue kraken -symbol BTC/USD
Both images are multi-stage: the Go service on gcr.io/distroless/static-debian12:nonroot (no shell,
non-root; 16.9 MB), the dashboard as a static export on nginx:1.29-alpine, run as an unprivileged user (93.6 MB).
The edge answers /healthz (the process is up) and /readyz (the book has a view and is not being
rebuilt). tickerplant -healthcheck -http :8080 asks /healthz from inside the container, where there is
no curl, and exits 0 or 1. -cors-origin https://app.example limits which origin a browser lets read the
edge (the default * lets any). -max-streams (default 256) caps the stream clients; the next one gets
a 503.
Without Docker: go run ./cmd/tickerplant -http :8080 -steps 100000000 for the edge, then
cd web && pnpm install && pnpm dev for the dashboard.
The Go build needs Go 1.21 or newer: with the default GOTOOLCHAIN=auto the go command fetches the
1.26.11 that go.mod asks for.
| Component | Status |
|---|---|
Canonical book model and Trade type (scaled integers, no float); no adapter emits trades |
Done — tested |
| Per-venue normalization to the canonical model | Done — tested (Binance, Kraken) |
| Order-book engine (snapshot + delta, gap detect, resync, invariants) | Done — tested |
Transport port + deterministic synthetic source (seeded, fault-injecting; -chaos runs a repeating fault schedule) |
Done — tested |
| Binance live adapter (WebSocket diff-depth + REST snapshot) | Done — tested (-live) |
| Kraken live adapter (WS v2 in-band book + CRC32 drift detection) | Done — tested (-live -venue kraken -symbol BTC/USD) |
| OKX live adapter | Not planned (two venues, see docs/scope.md) |
Fan-out delivery (internal/delivery, in-process, bounded backpressure) |
Done — tested |
Runnable demo (cmd/tickerplant: source → engine → fan-out) |
Done |
Dashboard (Next.js, web/: live book + health from the HTTP edge, no floats on the price path) |
Done — tested |
| Metrics: engine counters (gaps/resyncs/disconnects/refused snapshots) + latency histogram | Done — tested |
HTTP edge: SSE /stream (complete top-N views and a 1 Hz telemetry event), /metrics (Prometheus text), /api/status JSON, /healthz and /readyz (-http :8080; -cors-origin, -healthcheck) |
Done — tested |
| Benchmark harness (open-loop, coordinated-omission-aware, wire frames through the adapter) | Done — tested; one stated run published |
CI (.github/workflows/ci.yml: gofmt / vet / staticcheck / govulncheck / build, go mod tidy -diff, -race with shuffled test order, a coverage minimum per package, pinned actions and matching version pins; a front-end lint/format/type-check/test/build job that also runs the dashboard image, and a job that opens the built dashboard against a running edge in Chrome) |
Done |
Docker, docker-compose (docker compose up, synthetic by default) |
Done (docker compose build and up run by hand on 2026-10-24: both images build, the edge answers /healthz, the dashboard is served healthy as user nginx on a read-only file system and renders the live book; no CI job builds the images) |
Market-data infrastructure, not a trading system. Runs against public exchange feeds. Does not place orders, model risk, or look for trading opportunities.
MIT — see LICENSE.