File size: 536 Bytes
e35fd75 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import ccxt
import pandas as pd
exchange = ccxt.coinex({
'apiKey': 'YOUR_API_KEY',
'secret': 'YOUR_SECRET_KEY',
})
# Fetch OHLCV data for BTCUSDT
ohlcv = exchange.fetch_ohlcv('BTC/USDT', '1h', since=None, limit=100000)
# Convert OHLCV data to a pandas DataFrame
df = pd.DataFrame(ohlcv, columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
df.set_index('timestamp', inplace=True)
# Save the DataFrame to a pickle file
df.to_pickle('btcusdt_data.pkl')
|