GeneralPriceProvider
- class qf_lib.data_providers.general_price_provider.GeneralPriceProvider(bloomberg: Optional[BloombergDataProvider] = None, quandl: Optional[QuandlDataProvider] = None, haver: Optional[HaverDataProvider] = None)[source]
Bases:
DataProvider
The main class that should be used in order to access prices of financial instruments.
Methods:
get_futures_chain_tickers
(tickers, ...)Implements the functionality of DataProvider using duck-typing.
get_history
(tickers, fields, start_date[, ...])Implements the functionality of DataProvider using duck-typing.
get_price
(tickers, fields, start_date[, ...])Implements the functionality of AbstractPriceDataProvider using duck-typing.
Returns classes of tickers which are supported by this DataProvider.
- get_futures_chain_tickers(tickers: Union[FutureTicker, Sequence[FutureTicker]], expiration_date_fields: Union[ExpirationDateField, Sequence[ExpirationDateField]]) Dict[FutureTicker, Union[QFSeries, QFDataFrame]] [source]
Implements the functionality of DataProvider using duck-typing.
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.
- 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 QFSeries, consisting of the expiration dates of Future Contracts
- Return type:
Dict[FutureTicker, Union[QFSeries, QFDataFrame]]
- get_history(tickers: Union[Ticker, Sequence[Ticker]], fields: Union[str, Sequence[str]], start_date: datetime, end_date: Optional[datetime] = None, frequency: Frequency = Frequency.DAILY, **kwargs) Union[QFSeries, QFDataFrame, QFDataArray] [source]
Implements the functionality of DataProvider using duck-typing.
- Parameters:
tickers (Ticker, Sequence[Ticker]) – tickers for securities which should be retrieved
fields (None, str, Sequence[str]) – fields of securities which should be retrieved. If None, all available fields will be returned (only supported by few DataProviders)
start_date (datetime) – date representing the beginning of historical period from which data should be retrieved
end_date (datetime) – date representing the end of historical period from which data should be retrieved; if no end_date was provided, by default the current date will be used
frequency (Frequency) – frequency of the data
kwargs – kwargs should not be used on the level of AbstractDataProvider. They are here to provide a common interface for all data providers since some of the specific data providers accept additional arguments
- Returns:
If possible the result will be squeezed, so that instead of returning QFDataArray, data of lower dimensionality will be returned.
- Return type:
- get_price(tickers: Union[Ticker, Sequence[Ticker]], fields: Union[PriceField, Sequence[PriceField]], start_date: datetime, end_date: Optional[datetime] = None, frequency: Frequency = Frequency.DAILY, **kwargs) Union[None, PricesSeries, PricesDataFrame, QFDataArray] [source]
Implements the functionality of AbstractPriceDataProvider using duck-typing.
- Parameters:
tickers (Ticker, Sequence[Ticker]) – tickers for securities which should be retrieved
fields (PriceField, Sequence[PriceField]) – fields of securities which should be retrieved
start_date (datetime) – date representing the beginning of historical period from which data should be retrieved
end_date (datetime) – date representing the end of historical period from which data should be retrieved; if no end_date was provided, by default the current date will be used
frequency (Frequency) – frequency of the data
- Returns:
If possible the result will be squeezed so that instead of returning QFDataArray (3-D structure), data of lower dimensionality will be returned.
- Return type:
None, PricesSeries, PricesDataFrame, QFDataArray