Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Want to try first? Run pfeed in your browser — no install needed — at pfeed.pfund.ai.

import pfeed as pe

bybit = pe.Bybit()
feed = bybit.market_feed

1. Download Historical Data

result = feed.download(
    product="BTC_USDT_PERP",  # or BTC_USDT_PERPETUAL in full
    resolution="1minute",  # '1tick'/'1t' or '2second'/'2s' etc.
    start_date="2026-01-01",
    end_date="2026-01-01",
    io=pe.ParquetIO(),  # None to skip storing
)
df = result.data.collect()

2. Retrieve Stored Data

result = feed.retrieve(
    product="BTC_USDT_PERP",
    resolution="1m",  # 1-minute data
    start_date="2026-01-01",
    end_date="2026-01-01",
    io=pe.ParquetIO(),
)
df = result.data.collect()

3. Stream Live Data

feed.stream(
    product="BTC_USDT_CRYPTO",
    resolution="1tick",  # or just 'tick' for tick data
    # only DuckLake supports storing streamed data for now, set it to None to skip storing
    io=pe.DuckLakeIO(),
    callback=lambda msg: print(msg),
)

4. Replay Stored Data as a Stream

feed.replay(
    product="BTC_USDT_PERP",
    resolution="1m",
    start_date="2026-01-01",
    end_date="2026-01-01",
    io=pe.ParquetIO(),  # where the data was stored
    callback=lambda msg: print(msg),
)