ccxt-python
Skill này làm gì
Skill này là hướng dẫn xây dựng tính năng sàn tiền mã hóa trong dự án Python bằng thư viện CCXT. Nó dành cho lập trình viên, nhà phân tích và người xây bot làm việc bằng Python.
Khi nào nên dùng
- ✓Khi bạn đang viết mã Python để lấy giá hoặc lịch sử tiền mã hóa phục vụ phân tích.
- ✓Khi bạn cần đặt lệnh từ một bot giao dịch Python.
- ✓Khi bạn muốn cập nhật ticker hoặc sổ lệnh trực tiếp bằng Python.
Liên kết skill
https://github.com/ccxt/ccxt/blob/master/.claude/skills/ccxt-python/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Viết một script Python lấy giá BTC/USDT hiện tại từ Binance và in ra.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
AI cài gói ccxt bằng pip, tạo một đối tượng sàn và dùng lời gọi đồng bộ hoặc bất đồng bộ tùy theo tác vụ.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
CCXT for Python
A comprehensive guide to using CCXT in Python projects for cryptocurrency exchange integration.
Installation
REST API (Standard)
pip install ccxt
WebSocket API (Real-time, ccxt.pro)
pip install ccxt
Optional Performance Enhancements
pip install orjson # Faster JSON parsing
pip install coincurve # Faster ECDSA signing (45ms → 0.05ms)
Both REST and WebSocket APIs are included in the same package.
Quick Start
REST API - Synchronous
import ccxt
exchange = ccxt.binance()
exchange.load_markets()
ticker = exchange.fetch_ticker('BTC/USDT')
print(ticker)
REST API - Asynchronous
import asyncio
import ccxt.async_support as ccxt
async def main():
exchange = ccxt.binance()
await exchange.load_markets()
ticker = await exchange.fetch_ticker('BTC/USDT')
print(ticker)
await exchange.close() # Important!
asyncio.run(main())
WebSocket API - Real-time Updates
import asyncio
import ccxt.pro as ccxtpro
async def main():
exchange = ccxtpro.binance()
while True:
ticker = await exchange.watch_ticker('BTC/USDT')
print(ticker) # Live updates!
await exchange.close()
asyncio.run(main())
REST vs WebSocket
| Import | For REST | For WebSocket |
|---|---|---|
| Sync | import ccxt |
(WebSocket requires async) |
| Async | import ccxt.async_support as ccxt |
import ccxt.pro as ccxtpro |
| Feature | REST API | WebSocket API |
|---|---|---|
| Use for | One-time queries, placing orders | Real-time monitoring, live price feeds |
| Method prefix | 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 |
When to use REST:
- Placing orders
- Fetching account balance
- One-time data queries
- Order management (cancel, fetch orders)
When to use WebSocket:
- Real-time price monitoring
- Live orderbook updates
- Arbitrage detection
- Portfolio tracking with live updates
Creating Exchange Instance
REST API - Synchronous
import ccxt
# Public API (no authentication)
exchange = ccxt.binance({
'enableRateLimit': True # Recommended!
})
# Private API (with authentication)
exchange = ccxt.binance({
'apiKey': 'YOUR_API_KEY',
'secret': 'YOUR_SECRET',
'enableRateLimit': True
})
REST API - Asynchronous
import ccxt.async_support as ccxt
exchange = ccxt.binance({
'apiKey': 'YOUR_API_KEY',
'secret': 'YOUR_SECRET',
'enableRateLimit': True
})
# Always close when done
await exchange.close()
WebSocket API
import ccxt.pro as ccxtpro
# Public WebSocket
exchange = ccxtpro.binance()
# Private WebSocket (with authentication)
exchange = ccxtpro.binance({
'apiKey': 'YOUR_API_KEY',
'secret': 'YOUR_SECRET'
})
# Always close when done
await exchange.close()
Common REST Operations
Loading Markets
# Load all available trading pairs
exchange.load_markets()
# Access market information
btc_market = exchange.market('BTC/USDT')
print(btc_market['limits']['amount']['min']) # Minimum order amount
Fetching Ticker
# Single ticker
ticker = exchange.fetch_ticker('BTC/USDT')
print(ticker['last']) # Last price
print(ticker['bid']) # Best bid
print(ticker['ask']) # Best ask
print(ticker['volume']) # 24h volume
# Multiple tickers (if supported)
tickers = exchange.fetch_tickers(['BTC/USDT', 'ETH/USDT'])
Fetching Order Book
# Full orderbook
orderbook = exchange.fetch_order_book('BTC/USDT')
print(orderbook['bids'][0]) # [price, amount]
print(orderbook['asks'][0]) # [price, amount]
# Limited depth
orderbook = exchange.fetch_order_book('BTC/USDT', 5) # Top 5 levels
Creating Orders
Limit Order
# Buy limit order
order = exchange.create_limit_buy_order('BTC/USDT', 0.01, 50000)
print(order['id'])
# Sell limit order
order = exchange.create_limit_sell_order('BTC/USDT', 0.01, 60000)
# Generic limit order
order = exchange.create_order('BTC/USDT', 'limit', 'buy', 0.01, 50000)
Market Order
# Buy market order
order = exchange.create_market_
Câu hỏi thường gặp
Cài đặt thế nào?
Skill nói chạy pip install ccxt, gói này gồm cả hỗ trợ REST và WebSocket.
Có gói tăng tốc nào không?
Skill liệt kê các gói tùy chọn như orjson để phân tích JSON nhanh hơn và coincurve để ký nhanh hơn.
Kết nối bất đồng bộ có cần đóng không?
Có. Skill nói phải đóng kết nối sàn khi dùng phiên bản bất đồng bộ.
Chi tiết
Mô tả gốc của tác giả
CCXT cryptocurrency exchange library for Python 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 Python. Use when working with crypto exchanges in Python projects, trading bots, data analysis, or portfolio management. Supports both sync and async (asyncio) usage.
repo: ccxt/ccxt
Độ phổ biến
- Sao GitHub
- 45k
- Vị trí xếp hạng
- #6385
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
binance-agentic-wallet
45kCho agent của bạn quản lý ví Binance Web3 qua công cụ dòng lệnh baw, gồm đăng nhập, số dư, chuyển khoản, hoán đổi token và lệnh giới hạn.
binance-sports-ai-analyzer
45kGiúp agent của bạn tra cứu dự đoán trận đấu World Cup, phân tích AI và thông tin tin tức, rồi tính lại tỷ lệ thắng khi bạn điều chỉnh các tín hiệu.
binance-tokenized-securities-info
45kGiúp agent của bạn tra cứu cổ phiếu Mỹ token hóa Ondo trên Binance Web3: danh sách token, thông tin công ty, trạng thái giao dịch và giá on-chain.
binance
45kCho agent của bạn dùng Binance Spot, USD-M Futures và Convert qua công cụ binance-cli. Yêu cầu bạn thiết lập xác thực trước.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.