Skip to article frontmatterSkip to article content

Download Historical Data

import pfeed as pe

pe.__version__

Download Historical Data from BybitΒΆ

pe.bybit.download_historical_data(
    products=['BTC_USDT_PERP'],
    dtypes=['raw'],  # this will be converted to `raw_tick` implicitly for Bybit
    start_date='2024-03-01',
    end_date='2024-03-02',
    num_cpus=8,  # num_cpus for Ray
    use_ray=True,
    use_minio=False,
)

Now you can get your downloaded raw data locally by creating a Feed object:

if the data has not been downloaded, it will be downloaded on the fly automatically.

bybit_feed = pe.BybitFeed()
raw_df = bybit_feed.get_historical_data(
    product='BTC_USDT_PERP',
    resolution='raw',
    start_date='2024-03-01',
    end_date='2024-03-02',
)
raw_df.head(3)

Resample DataΒΆ

You can resample the downloaded raw data to other resolutions by specifying the resolution argument, e.g. 1m or 1minute for 1-minute data.

minute_df = bybit_feed.get_historical_data(
    product='BTC_USDT_PERP',
    resolution='1m',
    start_date='2024-03-01',
    end_date='2024-03-02',
)
minute_df.head(3)