import pfeed as pe
pe.__version__bybit_feed = pe.BybitFeed(data_tool='polars', use_ray=True)
yfinance_feed = pe.YahooFinanceFeed(data_tool='pandas', use_ray=False)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(1)Get Historical Data from Yahoo Finance¶
'''
yfinance_feed uses `yfinance` to fetch data,
so you can pass in kwargs supported by yfinance. Please refer to yfinance's doc:
https://ranaroussi.github.io/yfinance/index.html
'''
yfinance_kwargs = {}
yfinance_df = yfinance_feed.get_historical_data(
'TSLA_USD_STK', # STK = stock
resolution='1d', # 1-day data
start_date='2025-01-01',
end_date='2025-01-31',
**yfinance_kwargs
)yfinance_df.head(1)Auto-Resampling
Auto-resampling will be applied based on the data’s original resolution and the target resolution. e.g. if ‘1second’ data is downloaded and the target resolution is ‘1minute’, the data will be resampled accordingly.
Non-standard columns will be DROPPED because resampling logic is not defined for them. e.g. if resampling bybit’s tick data to ‘1minute’ data, the ‘tickDirection’ column will be dropped.
To avoid this data loss, use the same resolution as the downloaded data and perform resampling manually.