# <center> CCXT-Rust </center>
___
[](https://www.rust-lang.org/)
[](LICENSE)
[](https://github.com/Praying/ccxt-rust/actions/workflows/rust.yml)
[](https://docs.rs/ccxt-rust)
A professional-grade, type-safe Rust implementation of the CCXT library for cryptocurrency trading, providing unified
access to major exchanges.
## đ¯ Supported Exchanges
| **Binance** | â
| â
| â
|
| **Bitget** | â
| â
| â
|
| **Hyperliquid** | â
| â
| â
|
| **OKX** | â
| â
| â
|
| **Bybit** | â
| â
| â
|
> **Legend**: â
Supported, đ§ In Progress
## đ Key Features
- **đĄī¸ Type-Safe & Async**: Built on `Tokio` and `rust_decimal` for safe, high-performance financial operations.
- **đ Unified Interface**: Consistent `Exchange` trait 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
```bash
cargo add ccxt-rust
```
### Basic Usage
```rust
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/`](examples/) directory.
## đī¸ Architecture
The project is structured as a workspace:
- **`ccxt-core`**: Defines the unified `Exchange` and `WsExchange` traits, standard types, and error handling logic.
- **`ccxt-exchanges`**: Contains specific implementations (Binance, OKX, etc.).
## đŠ Feature Flags
| `rest` | REST API support | â
|
| `websocket` | WebSocket support | â
|
| `rustls-tls` | Use RustLS (recommended) | â
|
| `native-tls` | Use OpenSSL/Native TLS | â |
## đ ī¸ Development
```bash
# Run tests
cargo test
# Check code quality
cargo clippy --all-targets -- -D warnings
# Build documentation
cargo doc --open
```
## đ License & Support
MIT License. See [LICENSE](LICENSE).
- **Issues**: [GitHub Issues](https://github.com/Praying/ccxt-rust/issues)
- **Docs**: [docs.rs](https://docs.rs/ccxt-rust)
## â ī¸ 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.
---