P
PipsGrowth
← Back to Libraries

CCXT Library

Unified API for 100+ cryptocurrency exchanges. Trade Bitcoin, Ethereum, and altcoins across Binance, Coinbase, Kraken, and more with a single interface.

Difficulty: Intermediate
Category: Live Trading

Installation

$ pip install ccxt

Supported Exchanges

Binance
Coinbase
Kraken
Bitfinex
Bybit
OKX
KuCoin
Huobi

...and 90+ more exchanges

Code Examples

Connect to Exchange

Python
import ccxt
# Initialize exchange
exchange = ccxt.binance({
'apiKey': 'YOUR_API_KEY',
'secret': 'YOUR_SECRET',
'enableRateLimit': True,
})
# Get exchange info
print(f"Exchange: {exchange.name}")
print(f"Has: {exchange.has}")
# Fetch markets
markets = exchange.load_markets()
print(f"Available markets: {len(markets)}")
# Get ticker
ticker = exchange.fetch_ticker('BTC/USDT')
print(f"BTC/USDT Price: $ticker['last']:.2f}")

Download OHLCV Data

Python
import ccxt
import pandas as pd
exchange = ccxt.binance()
# Fetch OHLCV data
ohlcv = exchange.fetch_ohlcv('BTC/USDT', '1h', limit=100)
# Convert to DataFrame
df = pd.DataFrame(ohlcv, columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
print(df.tail())

Place Orders

Python
import ccxt
exchange = ccxt.binance({
'apiKey': 'YOUR_API_KEY',
'secret': 'YOUR_SECRET',
})
# Place market buy order
order = exchange.create_market_buy_order('BTC/USDT', 0.001)
print(f"Order ID: {order['id']}")
# Place limit order
limit_order = exchange.create_limit_buy_order('ETH/USDT', 0.1, 2000)
# Check order status
status = exchange.fetch_order(order['id'], 'BTC/USDT')
print(f"Status: {status['status']}")

Use Cases

  • Automated crypto trading bots
  • Cross-exchange arbitrage
  • Portfolio management across multiple exchanges