ccxt-rust
Fungsinya
Skill ini adalah panduan untuk membangun fitur bursa kripto di proyek Rust dengan crate CCXT. Skill ini ditujukan untuk developer yang membangun bot perdagangan atau layanan berlatensi rendah di Rust.
Kapan dipakai
- βSaat Anda membangun layanan Rust yang membaca data pasar kripto.
- βSaat Anda perlu memasang atau memeriksa order dari bot perdagangan Rust.
- βSaat Anda ingin pembaruan WebSocket langsung di proyek Rust.
Link skill
https://github.com/ccxt/ccxt/blob/master/.claude/skills/ccxt-rust/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βTulis program Rust yang mencetak ticker Binance BTC/USDT.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
AI menambahkan crate ccxt bersama tokio, membuat objek bursa yang bertipe, dan menunggu setiap metode yang mengembalikan hasil bertipe atau error.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
CCXT for Rust
A comprehensive guide to using CCXT in Rust projects for cryptocurrency exchange integration.
Every exchange has a typed wrapper (ccxt::Binance, ccxt::Kraken, β¦) exposing the unified
CCXT API with native Rust return types β Ticker, Order, OrderBook, Market β instead of a
dynamic value. All methods are async and return Result<T, ExchangeError>.
Installation
REST API
cargo add ccxt tokio --features tokio/full
WebSocket API (ccxt.pro)
cargo add ccxt-pro
Prediction markets
cargo add ccxt-prediction
Cargo.toml
[dependencies]
ccxt = "4.5.75" # REST exchanges (typed) β required
ccxt-pro = "4.5.75" # WebSocket (watch*) exchanges β only if you stream
ccxt-prediction = "4.5.75" # prediction markets β only if you trade them
tokio = { version = "1", features = ["full"] }
Requirements
- Rust stable, edition 2021 or later.
- A tokio runtime β every unified method is
async. There is no sync API. ccxtalone is enough for REST. Addccxt-proonly when you needwatch_*; it is a separate crate so a REST-only build does not compile the whole WebSocket surface.
Quick Start
REST API
use ccxt::{Binance, Params};
#[tokio::main]
async fn main() -> Result<(), ccxt::ExchangeError> {
let mut exchange = Binance::new(None);
exchange.load_markets(false).await;
let ticker = exchange.fetch_ticker("BTC/USDT", Params::none()).await?;
println!("{} last={:?} bid={:?} ask={:?}", ticker.symbol, ticker.last, ticker.bid, ticker.ask);
Ok(())
}
WebSocket API β real-time updates
use ccxt::Params;
use ccxt_pro::Binance;
#[tokio::main]
async fn main() -> Result<(), ccxt::ExchangeError> {
let mut exchange = Binance::new(None);
exchange.try_load_markets(false).await?;
loop {
let ticker = exchange.watch_ticker("BTC/USDT", Params::none()).await?;
println!("{:?}", ticker.last); // live updates
}
}
Each watch_* call resolves to one decoded update, so consuming a stream is just calling it in
a loop.
Crate layout
| Crate | Contains | Use when |
|---|---|---|
ccxt |
Typed REST wrappers (ccxt::Binance, β¦), Params, Config, types::*, TypedExchange. Re-exports the whole engine at its root. |
Always |
ccxt-pro |
Typed WebSocket wrappers (ccxt_pro::Binance, β¦) with watch_* |
Streaming |
ccxt-prediction |
Typed prediction-market wrappers (ccxt_prediction::Kalshi, β¦) |
Prediction markets |
ccxt-base |
The untyped engine (Value, HTTP, crypto, rate limiter, Cores, WS infra) |
Rarely direct β ccxt re-exports it |
ccxt re-exports ccxt-base at its root, so ccxt::Value, ccxt::runtime::β¦,
ccxt::exchanges::binance::BinanceCore resolve alongside the typed ccxt::Binance.
Coverage today: 105 typed REST venues, 76 typed WebSocket venues, 7 prediction venues.
REST vs WebSocket
| Feature | REST API | WebSocket API |
|---|---|---|
| Use for | One-time queries, placing orders | Real-time monitoring, live price feeds |
| Crate | ccxt |
ccxt-pro |
| Import | use ccxt::Binance; |
use ccxt_pro::Binance; |
| Methods | fetch_* (fetch_ticker, fetch_order_book) |
watch_* (watch_ticker, watch_order_book) |
| Speed | Slower (HTTP request/response) | Faster (persistent connection) |
| Rate limits | Strict (1β2 req/sec) | More lenient (continuous stream) |
| Best for | Trading, account management | Price monitoring, arbitrage detection |
Both crates expose a type named Binance. When you use both in one file, alias one of them:
use ccxt::Binance as BinanceRest;
use ccxt_pro::Binance as BinanceWs;
Runtime setup
Two settings matter in real programs and are easy to miss:
fn main() {
// 1. The transpiled core signals errors by panicking across an internal
// catch_unwind; the typed layer turns that back into `Result`. Silencing
// the default hook stops caught panics from printing to stderr.
// Set CCXT_SHOW_PANICS=1 to see them while debugging.
if std::env::var("CCXT_SHOW_PANICS").is_err() {
std::panic::set_hook(Box::new(|_| {}));
}
// 2. The generated exchange code is deeply nested β give worker threads a
// large stack. The default 2 MB can overflow on some venues.
let rt = tokio::runtime::Builder::new_multi_th
Pertanyaan umum
Apakah ada API sinkron?
Tidak. Skill menyebutkan setiap metode terpadu bersifat asinkron dan tidak ada API sinkron.
Apakah saya perlu crate WebSocket?
Hanya jika Anda melakukan streaming data langsung. Skill menyebutkan crate ccxt-pro terpisah dan diperlukan untuk fungsi watch.
Runtime apa yang dibutuhkan?
Skill membutuhkan runtime tokio dan versi Rust yang stabil, dengan edition 2021 atau lebih baru.
Detail
Deskripsi asli dari pembuat
CCXT cryptocurrency exchange library for Rust developers. Covers both REST API (standard) and WebSocket API (real-time). Helps install CCXT, connect to exchanges, fetch market data, place orders, stream live tickers/orderbooks, handle authentication, and manage errors in Rust projects. Use when working with crypto exchanges in Rust applications, trading bots, or low-latency services. Async (tokio), typed wrappers returning Result<T, ExchangeError>.
repo: ccxt/ccxt
Popularitas
- Bintang GitHub
- 45k
- Peringkat
- #6386
- Lisensi
- MIT
- Diperbarui
- 2/11/2026
Komentar
- β¦
Skill lain dari repositori ini
binance-agentic-wallet
45kMemungkinkan agent Anda mengelola dompet Web3 Binance lewat baris perintah baw, termasuk login, saldo, transfer, tukar token, dan order limit.
binance-sports-ai-analyzer
45kMembantu agent Anda melihat prediksi pertandingan Piala Dunia, analisis AI, dan wawasan berita, lalu menghitung ulang peluang menang saat sinyal diubah.
binance-tokenized-securities-info
45kMembantu agent Anda mencari saham AS yang ditokenisasi Ondo di Binance Web3, mencakup daftar token, info perusahaan, status perdagangan, dan harga on-chain.
binance
45kMemungkinkan agent Anda memakai Binance Spot, USD-M Futures, dan Convert lewat alat binance-cli. Anda perlu menyiapkan autentikasi terlebih dahulu.
Skill serupa
api-connector-builder
280kMembuat agent Anda membangun koneksi API baru mengikuti pola yang sudah ada. Gunakan saat ingin menambah integrasi lagi tanpa membuat cara baru.
api-design
280kMembantu agent Anda merancang REST API sesuai praktik terbaik. Berguna untuk mengatur cara API berkomunikasi, menampilkan error, dan mengorganisasi data.
backend-patterns
280kMembantu agent Anda dengan pola arsitektur sisi server dan optimasi database. Berguna untuk membangun atau meninjau kode yang berjalan di server.