A professional-grade, type-safe Rust implementation of the CCXT library for cryptocurrency trading, providing unified access to major exchanges.
| Exchange | Market Data | Trading | WebSocket |
|---|---|---|---|
| Binance | ✅ | ✅ | ✅ |
| Bitget | ✅ | ✅ | ✅ |
| Hyperliquid | ✅ | ✅ | ✅ |
| OKX | ✅ | ✅ | ✅ |
| Bybit | ✅ | ✅ | ✅ |
Legend: ✅ Supported, 🚧 In Progress
- 🛡️ 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.
cargo add ccxt-rustuse 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.
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.).
| Flag | Description | Default |
|---|---|---|
rest |
REST API support | ✅ |
websocket |
WebSocket support | ✅ |
rustls-tls |
Use RustLS (recommended) | ✅ |
native-tls |
Use OpenSSL/Native TLS | ❌ |
# Run tests
cargo test
# Check code quality
cargo clippy --all-targets -- -D warnings
# Build documentation
cargo doc --openMIT License. See LICENSE.
- Issues: GitHub Issues
- Docs: docs.rs
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