Skip to article frontmatterSkip to article content

Get Historical Data

import pfeed as pe

pe.__version__

Create Data FeedsΒΆ

bybit_feed = pe.BybitFeed(data_tool='polars')
yfinance_feed = pe.YahooFinanceFeed(data_tool='pandas')

Get Historical Data from BybitΒΆ

bybit_df = bybit_feed.get_historical_data(
    'BTC_USDT_PERP',
    rollback_period='2d',  # rollback 2 days
    resolution='1m',  # 1-minute data  
)

By calling just one line of code above, now you can play with the clean data returned.

bybit_df.collect().tail(3)

Get Historical Data from Yahoo FinanceΒΆ

yfinance_kwargs = {}  # please refer to yfinance's documentation for the supported kwargs
df = yfinance_feed.get_historical_data(
    'TSLA',
    resolution='1d',  # 1-day data
    start_date='2024-01-01',
    end_date='2024-01-31',
    **yfinance_kwargs
)
df.head(3)