I'm learning Rust and so I decided to work on this for fun.
A high-performance exchange built with Rust, featuring a multi-threaded architecture and HTTP API.
Ergodic is an exchange that processes orders and executes trades using a multi-threaded architecture. It's built with Rust for performance and reliability, using modern async/await patterns and channels for inter-thread communication.
- Multi-threaded architecture for high performance
- HTTP API for order submission and trade monitoring
- In-memory order book and matching engine
- Crossbeam channels for efficient inter-thread communication
- Built with Tokio for async runtime
- Axum for HTTP server implementation
The project is organized into several modules:
core.rs
: Core trading logic, order book, and matching engineengine.rs
: Main trading engine that processes orders and executes tradesapi.rs
: HTTP API endpoints for order submission and trade monitoringmain.rs
: Application entry point and thread orchestration
- tokio: Async runtime
- axum: HTTP server framework
- serde: Serialization/deserialization
- crossbeam: Thread-safe channels and synchronization primitives
- Rust 2024 edition
- Cargo package manager
- Clone the repository:
git clone https://github.com/yourusername/ergodic.git
cd ergodic
- Build the project:
cargo build --release
- Run the server:
cargo run --release
The server will start on 0.0.0.0:8080
.
POST /order
Content-Type: application/json
{
"symbol": "BTC/USD",
"side": "buy",
"price": 50000.0,
"quantity": 1.0
}
GET /trades
cargo build
cargo test
cargo run
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Rust's excellent concurrency primitives
- Inspired by modern trading system architectures