Skip to main content

Exchange

Exchange is a low-latency centralized cryptocurrency exchange designed for high-frequency trading (HFT). Built in Rust, it features an in-memory order book, real-time WebSocket updates, and an optimized backend powered by Redis and Postgres for maximum efficiency.

Quickstart

Get started with Exchange in minutes

Architecture

Learn about the system architecture

API reference

Explore the REST and WebSocket APIs

Key features

Exchange is designed for speed, reliability, and scalability. Here are the key features that make it production-ready:

Ultra-fast order matching

Sub-10ms order execution with an optimized matching engine that processes orders using price-time priority

In-memory order book & balances

All order books and user balances are stored in-memory for low latency and high throughput

Real-time WebSockets

Live updates for market depth, trades, and tickers pushed to connected clients in real-time

Advanced matching engine

Optimized price-time priority algorithm ensures fair and efficient order execution

Fault-tolerant architecture

Redis-backed pub/sub for message queuing and Postgres for persistent storage ensure data durability

Efficient API layer

RESTful HTTP and WebSocket APIs for seamless integration with trading clients and web interfaces

Tech stack

Exchange is built with modern, high-performance technologies:
  • Rust – Core language for speed and memory safety
  • Redis – High-speed pub/sub and caching layer
  • Postgres – Persistent storage for trade history and user balances
  • Tokio – Asynchronous runtime for high-performance networking
  • Actix – Web framework for API handling
  • Tokio-Tungstenite – WebSocket implementation for real-time data streaming
  • Serde – Serialization/deserialization of structured data
  • SQLx – Async database interaction with compile-time query verification
  • Fred – Efficient Redis client for pub/sub messaging

Performance

The exchange achieves sub-10ms order execution latency by:
  • Maintaining all order books and balances in-memory
  • Using Rust’s zero-cost abstractions for optimal performance
  • Processing orders asynchronously with Tokio
  • Leveraging Redis for fast inter-process communication
  • Decoupling database writes from the critical path
The exchange uses an in-memory architecture for speed. Make sure you have adequate RAM for your trading volumes and consider implementing proper backup strategies.

Use cases

Exchange is ideal for:
  • Cryptocurrency trading platforms requiring low-latency order execution
  • High-frequency trading (HFT) systems that need sub-10ms performance
  • Market makers who need fast order placement and cancellation
  • Educational purposes to learn how exchanges work under the hood

Open source

Exchange is open-source under the MIT License. You can find the source code on GitHub.

Build docs developers (and LLMs) love