data_providers¶
Data Provider classes
An interface for data providers (for example AbstractPriceDataProvider or GeneralPriceProvider). |
|
An interface for data providers containing historical data of stocks, indices, futures and other asset classes. |
|
Data Provider which provides financial data from Bloomberg. |
|
|
Data Provider which provides financial data from Bloomberg BEAP HAPI. |
Wrapper on QFDataArray which makes it a DataProvider. |
|
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. |
|
The main class that should be used in order to access prices of financial instruments. |
|
Class providing the Quandl data. |
|
Constructs a new |
|
Loads Portara data for futures contracts. |
|
Generic Data Provider that loads csv files. |
Functions
|
Returns only these tickers belonging to the chain of a given FutureTicker, which were valid only for the given time frame. |
|
Post-processes the result of some DataProviders so that it satisfies the format of a result expected from DataProviders. |
Converts a dictionary mapping tickers to DateFrame onto a QFDataArray. |
-
qf_lib.data_providers.helpers.
chain_tickers_within_range
(future_ticker: qf_lib.containers.futures.future_tickers.future_ticker.FutureTicker, exp_dates: qf_lib.containers.dataframe.qf_dataframe.QFDataFrame, start_date: datetime.datetime, end_date: datetime.datetime)[source]¶ Returns only these tickers belonging to the chain of a given FutureTicker, which were valid only for the given time frame.
As it is possible to select the contracts to be traded for a given future ticker (e.g. for Bloomberg future tickers we could specify only to trade “M” contracts), the end date is computed as the original end date + 1 year x contract number to trade. E.g. if we specify that we only want to trade “M” contracts and we always want to trade the front M contract, we add 1 year x 1. If instead of the front M, we would like to trade the second next M contract, we add 2 years to the end date etc.
-
qf_lib.data_providers.helpers.
normalize_data_array
(data_array, tickers, fields, got_single_date, got_single_ticker, got_single_field, use_prices_types=False) → Union[qf_lib.containers.series.qf_series.QFSeries, qf_lib.containers.dataframe.qf_dataframe.QFDataFrame, qf_lib.containers.qf_data_array.QFDataArray, qf_lib.containers.series.prices_series.PricesSeries, qf_lib.containers.dataframe.prices_dataframe.PricesDataFrame][source]¶ Post-processes the result of some DataProviders so that it satisfies the format of a result expected from DataProviders. Expected format rules should cover the following: - proper return type (QFSeries/PricesSeries, QFDataFrame/PricesDataFrame, QFDataArray), - proper shape of the result (squeezed dimensions for which a single non-list value was provided, e.g. “OPEN”), - dimensions: TICKERS and FIELDS contain all required labels and the labels are in required order.
- Parameters
data_array – data_array to be normalized
tickers – list of tickers requested by the caller
fields – list of fields requested by the caller
got_single_date – True if a single (scalar value) date was requested (start_date==end_date); False otherwise
got_single_ticker – True if a single (scalar value) ticker was requested (e.g. “MSFT US Equity”); False otherwise
got_single_field – True if a single (scalar value) field was requested (e.g. “OPEN”); False otherwise
use_prices_types – if True then proper return types are: PricesSeries, PricesDataFrame or QFDataArray; otherwise return types are: QFSeries, QFDataFrame or QFDataArray
- Returns
- Return type
QFSeries, QFDataFrame, QFDataArray, PricesSeries, PricesDataFrame
-
qf_lib.data_providers.helpers.
tickers_dict_to_data_array
(tickers_data_dict: Dict[qf_lib.common.tickers.tickers.Ticker, qf_lib.containers.dataframe.qf_dataframe.QFDataFrame], requested_tickers: Union[qf_lib.common.tickers.tickers.Ticker, Sequence[qf_lib.common.tickers.tickers.Ticker]], requested_fields) → qf_lib.containers.qf_data_array.QFDataArray[source]¶ Converts a dictionary mapping tickers to DateFrame onto a QFDataArray.
- Parameters
tickers_data_dict (Dict[Ticker, QFDataFrame]) – Ticker -> QFDataFrame[dates, fields]
requested_tickers (Sequence[Ticker]) –
requested_fields –
- Returns
- Return type