CCXT unified crypto exchange library (100+ exchanges). Free public market data. Fallback when OKX is unavailable.
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-ccxt-ee84a994cdef ,按照其中的说明把「ccxt」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
CCXT is a unified cryptocurrency exchange trading library supporting 100+ exchanges including Binance, Bybit, OKX, Coinbase, Kraken, and more. Public market data (OHLCV, tickers, order books) requires no API key.
pip install ccxtimport ccxt
exchange = ccxt.binance({"enableRateLimit": True})
# Fetch daily OHLCV
ohlcv = exchange.fetch_ohlcv("BTC/USDT", "1d", limit=100)
# Returns: [[timestamp, open, high, low, close, volume], ...]
# Fetch ticker
ticker = exchange.fetch_ticker("ETH/USDT")
print(f"ETH price: {ticker['last']}")
| Method | Description | Returns |
|---|---|---|
fetch_ohlcv(symbol, timeframe, since, limit) | Historical candles | [[ts, o, h, l, c, v], ...] |
fetch_ticker(symbol) | Latest quote | {last, bid, ask, volume, ...} |
fetch_tickers(symbols) | Batch quotes | {symbol: ticker} |
fetch_order_book(symbol, limit) | Order book | {bids, asks, timestamp} |
fetch_trades(symbol, since, limit) | Recent trades | [{price, amount, side, timestamp}, ...] |
1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d, 1w, 1M
Note: not all exchanges support all timeframes. Use exchange.timeframes to check.
CCXT uses slash format: BTC/USDT, ETH/BTC, SOL/USDT
The project's DataLoader automatically converts BTC-USDT (hyphen) to BTC/USDT (slash).
Set via environment variable: CCXT_EXCHANGE=binance (default)
Popular exchanges: binance, bybit, okx, coinbase, kraken, bitget, gate
The project has a built-in CCXT DataLoader at backtest/loaders/ccxt_loader.py. It serves as a fallback when the OKX loader is unavailable.
For long history, CCXT paginates via the since parameter (millisecond timestamp). The built-in loader handles this automatically (up to 200 pages).