quantlab.dataset.spot.SpotKlineDataset#

class quantlab.dataset.spot.SpotKlineDataset(dataset_config)[source]#

Bases: RawMarketDataset

Binance spot kline dataset built from monthly CSV files.

The raw directory holds one header-less CSV per symbol and month, named <SYMBOL>-...csv. The column names come from BinanceCSVHeaders.SPOT and the symbol comes from the file name. Columns keep Binance’s Title-Case spelling (Open, High, …); COLUMN_MAP renames them to the shared lowercase names in to_kunquant and in a merge.

Parameters:
dataset_configDatasetConfig

Paths (raw CSV directory, Zarr store, Nautilus catalog), market, frequency and date range of the dataset.

Examples

>>> config = DatasetConfig(
...     raw_data_dir_path="downloads/crypto_spot/1d/klines",
...     zarr_file_path="data/crypto_spot/1d/spot.zarr",
...     market="crypto_spot",
...     frequency="1d",
... )
>>> SpotKlineDataset(config).from_raw_data().save()
>>> panel = SpotKlineDataset(config).panel("2024-01-01", "2024-12-31")
COLUMN_MAP = {'Close': 'close', 'High': 'high', 'Low': 'low', 'Open': 'open', 'Quote asset volume': 'amount', 'Volume': 'volume'}#

Quote asset volume (traded value in the quote currency) becomes amount and the OHLCV columns are lowercased.