Historical Downloader (dccd.histo_dl)¶
Module to download historical OHLCV, trades, and order book data.
Supports five exchanges via REST APIs: Binance, Bybit, Coinbase, Kraken,
and OKX. All exchange classes inherit from
ImportDataCryptoCurrencies and expose
the same interface:
from dccd.histo_dl import FromBinance
obj = FromBinance('/path/to/data/', 'BTC', 3600, fiat='USDT')
# OHLCV — download and save as annual Parquet
obj.import_data(start='2024-01-01 00:00:00', end='now').save(form='parquet')
df = obj.get_data() # pandas DataFrame
# Incremental update (resume from last saved timestamp)
obj.import_data(start='last', end='now').save(form='parquet')
# Trades (Binance/Kraken support full history; Bybit/Coinbase recent only)
obj.import_trades(start='2024-01-01', end='2024-01-02').save_trades()
df_trades = obj.trades_df # columns: tid, timestamp, price, amount, type
# Order book snapshot
obj.import_orderbook(depth=50).save_orderbook()
df_book = obj.orderbook_df # columns: side, price, amount, count
Data are stored via DataStore under:
{data_path}/{exchange}/ohlc/{pair}/{span}/YYYY.parquet
{data_path}/{exchange}/trades/{pair}/YYYY-MM-DD.parquet
{data_path}/{exchange}/orderbook/{pair}/YYYY-MM-DD.parquet
Downloads OHLCV candles, trade history, and order book snapshots from
exchange REST APIs. All exchange classes share the same fluent interface
and inherit from ImportDataCryptoCurrencies.
Typical workflow¶
from dccd.histo_dl import FromBinance
obj = FromBinance('/data/crypto/', 'BTC', span=3600, fiat='USDT')
# Download and persist
obj.import_data(start='2024-01-01 00:00:00', end='2024-12-31 00:00:00')
obj.save(form='parquet')
# Load back as a Polars DataFrame
df = obj.get_data()
Resuming an interrupted download¶
Pass start='last' to resume from the latest saved timestamp:
obj.import_data(start='last', end='now').save(form='parquet')
On the first run this downloads everything; on subsequent runs it resumes without duplicate rows. Combine with cron or the Daemon (dccd.daemon) for automated incremental collection.
Supported spans¶
All exchanges support at least the spans below. Exchange-specific pages document additional intervals.
Span (s) |
Label |
Binance |
Kraken |
Bybit |
OKX |
Coinbase |
|---|---|---|---|---|---|---|
60 |
1m |
✓ |
✓ |
✓ |
✓ |
✓ |
300 |
5m |
✓ |
✓ |
✓ |
✓ |
✓ |
900 |
15m |
✓ |
✓ |
✓ |
✓ |
✓ |
3600 |
1h |
✓ |
✓ |
✓ |
✓ |
✓ |
14400 |
4h |
✓ |
✓ |
✓ |
✓ |
✓ |
86400 |
1d |
✓ |
✓ |
✓ |
✓ |
✓ |
Each exchange has additional constraints (pair format, candles per request, trade history availability) — see the exchange-specific pages below.
Exchange classes¶
|
Class to import crypto-currencies data from the Binance exchange. |
|
Class to import crypto-currencies data from the Coinbase exchange. |
|
Class to import crypto-currencies data from the Kraken exchange. |
|
Class to import crypto-currencies data from the Bybit exchange. |
|
Class to import crypto-currencies data from the OKX exchange. |