FuturesDataProvider#
- class qf_lib.data_providers.futures_data_provider.FuturesDataProvider[source]#
Bases:
objectAn interface for providers of futures’ data.
- abstractmethod expiration_date_field_str_map(ticker: Ticker = None) Dict[ExpirationDateField, str][source]#
Method has to be implemented in each data provider in order to be able to use get_futures_chain_tickers. Returns dictionary containing mapping between ExpirationDateField and corresponding string that has to be used by get_futures_chain_tickers method.
- Parameters:
ticker (None, Ticker) – ticker is optional and might be uses by particular data providers to create appropriate dictionary
- Returns:
mapping between ExpirationDateField and corresponding strings
- Return type:
Dict[ExpirationDateField, str]
- get_futures_chain_tickers(tickers: FutureTicker | Sequence[FutureTicker], expiration_date_fields: ExpirationDateField | Sequence[ExpirationDateField]) Dict[FutureTicker, QFDataFrame][source]#
Returns tickers of futures contracts, which belong to the same futures contract chain as the provided ticker (tickers), along with their expiration dates in form of a QFSeries or QFDataFrame.
- Parameters:
tickers (FutureTicker, Sequence[FutureTicker]) – tickers for which should the future chain tickers be retrieved
expiration_date_fields (ExpirationDateField, Sequence[ExpirationDateField]) – field that should be downloaded as the expiration date field, by default last tradeable date
- Returns:
Returns a dictionary, which maps Tickers to QFDataFrame, consisting of the expiration dates of Future Contracts: Dict[FutureTicker, QFDataFrame]]. The QFDataFrames contain the specific Tickers, which belong to the corresponding futures family, same as the FutureTicker, and are indexed by the expiration dates of the specific future contracts.
- Return type:
Dict[FutureTicker, QFDataFrame]