class qf_lib.data_providers.prefetching_data_provider.PrefetchingDataProvider(data_provider: qf_lib.data_providers.data_provider.DataProvider, tickers: Union[qf_lib.common.tickers.tickers.Ticker, Sequence[qf_lib.common.tickers.tickers.Ticker]], fields: Union[qf_lib.common.enums.price_field.PriceField, Sequence[qf_lib.common.enums.price_field.PriceField]], start_date: datetime.datetime, end_date: datetime.datetime, frequency: qf_lib.common.enums.frequency.Frequency)[source]

Bases: qf_lib.data_providers.preset_data_provider.PresetDataProvider

Optimises running of the DataProvider by pre-fetching all the data at startup and then using the cached data instead of sending over-the-network requests every time the data is requested. If not all data requested is available the ValueError will be raised.

  • data_provider (DataProvider) – data provider used to download the data

  • tickers (Ticker, Sequence[Ticker]) – one or a list of tickers, used further to download the futures contracts related data. The list can contain either Tickers or FutureTickers. In case of the Tickers, simply the given fields are being downloaded and stored using the PresetDataProvider. In case of the FutureTickers, the future chain tickers and their corresponding prices are being downloaded and stored.

  • fields (PriceField, Sequence[PriceField]) – fields that should be downloaded

  • start_date (datetime) – first date to be downloaded

  • end_date (datetime) – last date to be downloaded

  • frequency (Frequency) – frequency of the data