ccxt-rust
できること
このスキルは、CCXTのクレートを使ってRustプロジェクトで暗号資産の取引所の機能を作るためのガイドです。Rustで取引ボットや低遅延のサービスを作る開発者向けです。
使う場面
- ✓暗号資産の市場データを読むRustのサービスを作っているとき。
- ✓Rustの取引ボットから注文を出したり、確認したりする必要があるとき。
- ✓Rustプロジェクトで、ライブのWebSocketの更新がほしいとき。
スキルのリンク
https://github.com/ccxt/ccxt/blob/master/.claude/skills/ccxt-rust/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“BinanceのBTC/USDTのティッカーを表示するRustのプログラムを書いてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIは、tokioと一緒にccxtクレートを追加し、型付きの取引所のオブジェクトを作ります。そして、各メソッドを待機します。メソッドは型付きの結果か、エラーを返します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)を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
よくある質問
同期版のAPIはありますか?
いいえ。スキルによると、統一されたメソッドはすべて非同期で、同期版のAPIはありません。
WebSocketのクレートは必要ですか?
ライブのデータを受け取る場合だけ必要です。スキルによると、ccxt-proクレートは別のもので、watch関数に必要です。
必要なランタイムは何ですか?
スキルは、tokioのランタイムと、安定版のRust、エディション2021以降を必要とします。
詳細
作者による元の説明
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
人気
- GitHubのスター
- 45k
- ランキング
- #6386
- ライセンス
- MIT
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
binance-agentic-wallet
45kbawコマンドラインツールを通じて、Binance Web3ウォレットを管理できるようにします。サインイン、残高、送金、トークンのスワップ、指値注文を扱います。
binance-sports-ai-analyzer
45kワールドカップの試合の予想、AIによる分析、ニュースの洞察を調べ、シグナルを調整したあとに勝率を計算し直すのを支援します。
binance-tokenized-securities-info
45kトークンの一覧、企業情報、取引状況、オンチェーン価格を含め、Binance Web3上のOndoのトークン化された米国株について調べられるようにします。
binance
45kbinance-cliツールを通じて、Binance Spot、USD-M Futures、Convertを使えるようにします。最初に認証の設定が必要です。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。