Stock Exchange — Notes
Functional
- Limit / market / stop orders, IOC/FOK, hidden, iceberg.
- Price-time priority matching.
- Order amend / cancel.
- Market data feeds (L1/L2/L3).
- Clearing + settlement.
- Surveillance.
Non-functional
- Sub-millisecond engine latency.
- Determinism for replay.
- Audit + regulatory compliance.
- 99.999% during market hours.
Capacity
- NYSE peak ~10M msg/s.
- Per-symbol QPS depends on liquidity; HFT firms send 100k msgs/s for one ticker.
Schema
orders(id, client_id, symbol, side, type, qty, price, ts, status)
executions(id, order_id, qty, price, ts)
- Order book in-memory only; persisted via event log.
Trade-offs
- Single-threaded engine per symbol = deterministic + simple; cap is one core's throughput.
- Tail-latency obsession: pre-allocated memory, no GC pauses, kernel bypass NICs (DPDK / Solarflare).
- Replicate via event stream (not state) to keep replicas deterministic.
Refs
- LMAX architecture (high-performance trading) talks.
- NYSE Pillar paper; Nasdaq INET docs.
- "Trading at the speed of light" book.
- ByteByteGo "Design exchange / order book".