GeneralPriceProvider¶
-
class
qf_lib.data_providers.general_price_provider.
GeneralPriceProvider
(bloomberg: qf_lib.data_providers.bloomberg.bloomberg_data_provider.BloombergDataProvider = None, quandl: qf_lib.data_providers.quandl.quandl_data_provider.QuandlDataProvider = None, haver: qf_lib.data_providers.haver.haver_data_provider.HaverDataProvider = None)[source]¶ Bases:
qf_lib.data_providers.data_provider.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, …)Implements the functionality of DataProvider using duck-typing.
get_price
(tickers, …)Implements the functionality of AbstractPriceDataProvider using duck-typing.
Returns classes of tickers which are supported by this DataProvider.
-
get_futures_chain_tickers
(tickers: Union[qf_lib.containers.futures.future_tickers.future_ticker.FutureTicker, Sequence[qf_lib.containers.futures.future_tickers.future_ticker.FutureTicker]], expiration_date_fields: Union[qf_lib.common.enums.expiration_date_field.ExpirationDateField, Sequence[qf_lib.common.enums.expiration_date_field.ExpirationDateField]]) → Dict[qf_lib.containers.futures.future_tickers.future_ticker.FutureTicker, Union[qf_lib.containers.series.qf_series.QFSeries, qf_lib.containers.dataframe.qf_dataframe.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[qf_lib.common.tickers.tickers.Ticker, Sequence[qf_lib.common.tickers.tickers.Ticker]], fields: Union[str, Sequence[str]], start_date: datetime.datetime, end_date: datetime.datetime = None, frequency: qf_lib.common.enums.frequency.Frequency = <Frequency.DAILY: 252>, **kwargs) → Union[qf_lib.containers.series.qf_series.QFSeries, qf_lib.containers.dataframe.qf_dataframe.QFDataFrame, qf_lib.containers.qf_data_array.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[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 = None, frequency: qf_lib.common.enums.frequency.Frequency = <Frequency.DAILY: 252>) → Union[None, qf_lib.containers.series.prices_series.PricesSeries, qf_lib.containers.dataframe.prices_dataframe.PricesDataFrame, qf_lib.containers.qf_data_array.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
-