qiskit-documentation/docs/api/qiskit/0.26/qiskit.finance.data_provide...

160 lines
11 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: ExchangeDataProvider (v0.26)
description: API reference for qiskit.finance.data_providers.ExchangeDataProvider in qiskit v0.26
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.finance.data_providers.ExchangeDataProvider
---
<span id="qiskit-finance-data-providers-exchangedataprovider" />
# qiskit.finance.data\_providers.ExchangeDataProvider
<Class id="qiskit.finance.data_providers.ExchangeDataProvider" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.9/qiskit/finance/data_providers/exchange_data_provider.py" signature="ExchangeDataProvider(token, tickers, stockmarket=<StockMarket.LONDON: 'XLON'>, start=datetime.datetime(2016, 1, 1, 0, 0), end=datetime.datetime(2016, 1, 30, 0, 0))" modifiers="class">
Exchange data provider.
Please see: [https://github.com/Qiskit/qiskit-tutorials/blob/stable/0.25.x/tutorials/finance/11\_time\_series.ipynb](https://github.com/Qiskit/qiskit-tutorials/blob/stable/0.25.x/tutorials/finance/11_time_series.ipynb) for instructions on use, which involve obtaining a Quandl access token.
Initializer :type token: `str` :param token: quandl access token :type tickers: `Union`\[`str`, `List`\[`str`]] :param tickers: tickers :type stockmarket: `StockMarket` :param stockmarket: LONDON, EURONEXT, or SINGAPORE :type start: `datetime` :param start: first data point :type end: `datetime` :param end: last data point precedes this date
**Raises**
* [**MissingOptionalLibraryError**](qiskit.aqua.MissingOptionalLibraryError "qiskit.aqua.MissingOptionalLibraryError") Quandl not installed
* [**QiskitFinanceError**](qiskit.finance.QiskitFinanceError "qiskit.finance.QiskitFinanceError") provider doesnt support given stock market
### \_\_init\_\_
<Function id="qiskit.finance.data_providers.ExchangeDataProvider.__init__" signature="__init__(token, tickers, stockmarket=<StockMarket.LONDON: 'XLON'>, start=datetime.datetime(2016, 1, 1, 0, 0), end=datetime.datetime(2016, 1, 30, 0, 0))">
Initializer :type token: `str` :param token: quandl access token :type tickers: `Union`\[`str`, `List`\[`str`]] :param tickers: tickers :type stockmarket: `StockMarket` :param stockmarket: LONDON, EURONEXT, or SINGAPORE :type start: `datetime` :param start: first data point :type end: `datetime` :param end: last data point precedes this date
**Raises**
* [**MissingOptionalLibraryError**](qiskit.aqua.MissingOptionalLibraryError "qiskit.aqua.MissingOptionalLibraryError") Quandl not installed
* [**QiskitFinanceError**](qiskit.finance.QiskitFinanceError "qiskit.finance.QiskitFinanceError") provider doesnt support given stock market
</Function>
## Methods
| | |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`__init__`](#qiskit.finance.data_providers.ExchangeDataProvider.__init__ "qiskit.finance.data_providers.ExchangeDataProvider.__init__")(token, tickers\[, stockmarket, …]) | Initializer :type token: `str` :param token: quandl access token :type tickers: `Union`\[`str`, `List`\[`str`]] :param tickers: tickers :type stockmarket: `StockMarket` :param stockmarket: LONDON, EURONEXT, or SINGAPORE :type start: `datetime` :param start: first data point :type end: `datetime` :param end: last data point precedes this date |
| [`get_coordinates`](#qiskit.finance.data_providers.ExchangeDataProvider.get_coordinates "qiskit.finance.data_providers.ExchangeDataProvider.get_coordinates")() | Returns random coordinates for visualisation purposes. |
| [`get_covariance_matrix`](#qiskit.finance.data_providers.ExchangeDataProvider.get_covariance_matrix "qiskit.finance.data_providers.ExchangeDataProvider.get_covariance_matrix")() | Returns the covariance matrix. |
| [`get_mean_vector`](#qiskit.finance.data_providers.ExchangeDataProvider.get_mean_vector "qiskit.finance.data_providers.ExchangeDataProvider.get_mean_vector")() | Returns a vector containing the mean value of each asset. |
| [`get_period_return_covariance_matrix`](#qiskit.finance.data_providers.ExchangeDataProvider.get_period_return_covariance_matrix "qiskit.finance.data_providers.ExchangeDataProvider.get_period_return_covariance_matrix")() | Returns a vector containing the mean value of each asset. |
| [`get_period_return_mean_vector`](#qiskit.finance.data_providers.ExchangeDataProvider.get_period_return_mean_vector "qiskit.finance.data_providers.ExchangeDataProvider.get_period_return_mean_vector")() | Returns a vector containing the mean value of each asset. |
| [`get_similarity_matrix`](#qiskit.finance.data_providers.ExchangeDataProvider.get_similarity_matrix "qiskit.finance.data_providers.ExchangeDataProvider.get_similarity_matrix")() | Returns time-series similarity matrix computed using dynamic time warping. |
| [`run`](#qiskit.finance.data_providers.ExchangeDataProvider.run "qiskit.finance.data_providers.ExchangeDataProvider.run")() | Loads data, thus enabling get\_similarity\_matrix and get\_covariance\_matrix methods in the base class. |
### get\_coordinates
<Function id="qiskit.finance.data_providers.ExchangeDataProvider.get_coordinates" signature="get_coordinates()">
Returns random coordinates for visualisation purposes.
**Return type**
`Tuple`\[`ndarray`, `ndarray`]
</Function>
### get\_covariance\_matrix
<Function id="qiskit.finance.data_providers.ExchangeDataProvider.get_covariance_matrix" signature="get_covariance_matrix()">
Returns the covariance matrix.
**Return type**
`ndarray`
**Returns**
an asset-to-asset covariance matrix.
**Raises**
[**QiskitFinanceError**](qiskit.finance.QiskitFinanceError "qiskit.finance.QiskitFinanceError") no data loaded
</Function>
### get\_mean\_vector
<Function id="qiskit.finance.data_providers.ExchangeDataProvider.get_mean_vector" signature="get_mean_vector()">
Returns a vector containing the mean value of each asset.
**Return type**
`ndarray`
**Returns**
a per-asset mean vector.
**Raises**
[**QiskitFinanceError**](qiskit.finance.QiskitFinanceError "qiskit.finance.QiskitFinanceError") no data loaded
</Function>
### get\_period\_return\_covariance\_matrix
<Function id="qiskit.finance.data_providers.ExchangeDataProvider.get_period_return_covariance_matrix" signature="get_period_return_covariance_matrix()">
Returns a vector containing the mean value of each asset.
**Return type**
`ndarray`
**Returns**
a per-asset mean vector.
**Raises**
[**QiskitFinanceError**](qiskit.finance.QiskitFinanceError "qiskit.finance.QiskitFinanceError") no data loaded
</Function>
### get\_period\_return\_mean\_vector
<Function id="qiskit.finance.data_providers.ExchangeDataProvider.get_period_return_mean_vector" signature="get_period_return_mean_vector()">
Returns a vector containing the mean value of each asset.
**Return type**
`ndarray`
**Returns**
a per-asset mean vector.
**Raises**
[**QiskitFinanceError**](qiskit.finance.QiskitFinanceError "qiskit.finance.QiskitFinanceError") no data loaded
</Function>
### get\_similarity\_matrix
<Function id="qiskit.finance.data_providers.ExchangeDataProvider.get_similarity_matrix" signature="get_similarity_matrix()">
Returns time-series similarity matrix computed using dynamic time warping.
**Return type**
`ndarray`
**Returns**
an asset-to-asset similarity matrix.
**Raises**
[**QiskitFinanceError**](qiskit.finance.QiskitFinanceError "qiskit.finance.QiskitFinanceError") no data loaded
</Function>
### run
<Function id="qiskit.finance.data_providers.ExchangeDataProvider.run" signature="run()">
Loads data, thus enabling get\_similarity\_matrix and get\_covariance\_matrix methods in the base class.
**Return type**
`None`
</Function>
</Class>