ExchangeOS
Low-latency order-matching engine — price-time-priority matching, fixed-point math, Redis Pub/Sub, TimescaleDB.
- Category
- TypeScript
- Stack
- TypeScript, Node.js, Redis, TimescaleDB, WebSocket
- Code
- GitHub ↗
- Live
- —
Overview
ExchangeOS is a low-latency order-matching engine built on a microservices design — API gateway, matching engine, WebSocket server, and DB processor — for scalable, isolated trade execution. It implements a deterministic price-time-priority matching algorithm with O(log n) order insertion and precise fixed-point arithmetic, propagating the orderbook in real time over Redis Pub/Sub and WebSockets.
Matching engine
Deterministic price-time priority with O(log n) order insertion and fixed-point math via decimal.js; atomic balance locking and settlement, configurable self-trade-prevention modes, and periodic (3s) snapshot persistence.
Async architecture
The API gateway and engine communicate through Redis queues in a request-response-over-queue pattern — the API subscribes to a unique response channel, pushes the order, and the engine replies via Pub/Sub, so the API confirms fast without waiting on the database write.
Storage & market data
A DB processor consumes engine output and writes to TimescaleDB hypertables (orders, trades, prices), with candlestick/kline aggregation driving the time-series charts.
Built with
- TypeScript
- Node.js
- Redis
- TimescaleDB
- WebSocket