5 releases
Uses new Rust 2024
| 0.1.4 | Jan 30, 2026 |
|---|---|
| 0.1.3 | Jan 22, 2026 |
| 0.1.2 | Jan 3, 2026 |
| 0.1.1 | Dec 27, 2025 |
| 0.1.0 | Dec 13, 2025 |
#3 in #cryptocurrency-exchange
488 downloads per month
Used in ethcli
3MB
52K
SLoC
CCXT-Rust
A professional-grade, type-safe Rust implementation of the CCXT library for cryptocurrency trading, providing unified access to major exchanges.
🎯 Supported Exchanges
| Exchange | Market Data | Trading | WebSocket |
|---|---|---|---|
| Binance | ✅ | ✅ | ✅ |
| Bitget | ✅ | ✅ | ✅ |
| Hyperliquid | ✅ | ✅ | ✅ |
| OKX | ✅ | ✅ | ✅ |
| Bybit | ✅ | ✅ | ✅ |
Legend: ✅ Supported, 🚧 In Progress
🌟 Key Features
- 🛡️ Type-Safe & Async: Built on
Tokioandrust_decimalfor safe, high-performance financial operations. - 🔄 Unified Interface: Consistent
Exchangetrait across all supported exchanges. - ⚡ Real-Time: Robust WebSocket support with automatic reconnection.
- 📦 Comprehensive Capability:
- Market Data: Tickers, Order Books, OHLCV, Trades.
- Trading: Spot, Margin, Futures, Batched Orders, OCO.
- Account: Balances, Transactions, Leverage management.
🚀 Quick Start
Installation
cargo add ccxt-rust
Basic Usage
use ccxt_exchanges::binance::Binance;
use ccxt_core::exchange::Exchange;
use rust_decimal_macros::dec;
use ccxt_core::types::{OrderType, OrderSide};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// 1. Initialize (using env vars recommended)
let exchange = Binance::builder()
.api_key(std::env::var("BINANCE_API_KEY").ok())
.secret(std::env::var("BINANCE_SECRET").ok())
.build()?;
// 2. Fetch Market Data
let ticker = exchange.fetch_ticker("BTC/USDT").await?;
println!("BTC/USDT Price: {:?}", ticker.last);
// 3. Place Order (if credentials provided)
if exchange.has_private_api() {
let order = exchange.create_order(
"BTC/USDT",
OrderType::Limit,
OrderSide::Buy,
dec!(0.001),
Some(dec!(50000)),
).await?;
println!("Order placed: {}", order.id);
}
Ok(())
}
For WebSocket examples and advanced usage (polymorphism), see the examples/ directory.
🏗️ Architecture
The project is structured as a workspace:
ccxt-core: Defines the unifiedExchangeandWsExchangetraits, standard types, and error handling logic.ccxt-exchanges: Contains specific implementations (Binance, OKX, etc.).
🚩 Feature Flags
| Flag | Description | Default |
|---|---|---|
rest |
REST API support | ✅ |
websocket |
WebSocket support | ✅ |
rustls-tls |
Use RustLS (recommended) | ✅ |
native-tls |
Use OpenSSL/Native TLS | ❌ |
🛠️ Development
# Run tests
cargo test
# Check code quality
cargo clippy --all-targets -- -D warnings
# Build documentation
cargo doc --open
📝 License & Support
MIT License. See LICENSE.
- Issues: GitHub Issues
- Docs: docs.rs
⚠️ Disclaimer
This project is for educational and research purposes only. The authors and contributors are not responsible for any financial losses or damages arising from the use of this software. Cryptocurrency trading involves high risk; please trade responsibly.
Status: 🚧 Active Development (v0.1.4) | Donations (BSC): 0x8e5d858f92938b028065d39450421d0e080d15f7
Dependencies
~27–53MB
~791K SLoC