investpy.certificates
ΒΆ
-
investpy.certificates.
get_certificate_countries
()ΒΆ This function retrieves all the available countries to retrieve certificates from, as the listed countries are the ones indexed on Investing.com. The purpose of this function is to list the countries which have available certificates according to Investing.com data, since the country parameter is needed when retrieving data from any certificate available.
- Returns
The resulting
list
contains all the countries listed on Investing.com with available certificates to retrieve data from.In the case that the file reading of certificate_countries.csv which contains the names of the available countries with certificates was successfully completed, the resulting
list
will look like:countries = ['france', 'germany', 'italy', 'netherlands', 'sweden']
- Return type
list
- countries- Raises
FileNotFoundError β raised when certificate_countries.csv file was not found.
-
investpy.certificates.
get_certificate_historical_data
(certificate, country, from_date, to_date, as_json=False, order='ascending', interval='Daily')ΒΆ This function retrieves historical data from the introduced certificate from Investing.com. So on, the historical data of the introduced certificate from the specified country in the specified date range will be retrieved and returned as a
pandas.DataFrame
if the parameters are valid and the request to Investing.com succeeds. Note that additionally some optional parameters can be specified: as_json and order, which let the user decide if the data is going to be returned as ajson
or not, and if the historical data is going to be ordered ascending or descending (where the index is the date), respectively.- Parameters
certificate (
str
) β name of the certificate to retrieve historical data from.country (
str
) β name of the country from where the certificate is.from_date (
str
) β date formatted as dd/mm/yyyy, since when data is going to be retrieved.to_date (
str
) β date formatted as dd/mm/yyyy, until when data is going to be retrieved.as_json (
bool
, optional) β to determine the format of the output data, either apandas.DataFrame
if False and ajson
if True.order (
str
, optional) β to define the order of the retrieved data which can either be ascending or descending.interval (
str
, optional) β value to define the historical data interval to retrieve, by default Daily, but it can also be Weekly or Monthly.
- Returns
The function can return either a
pandas.DataFrame
or ajson
object, containing the retrieved historical data of the specified certificate from the specified country. So on, the resulting dataframe contains the OHLC values for the selected certificate on market days.The returned data is case we use default arguments will look like:
Date || Open | High | Low | Close -----||------|------|-----|------- xxxx || xxxx | xxxx | xxx | xxxxx
but if we define as_json=True, then the output will be:
{ name: name, historical: [ { date: 'dd/mm/yyyy', open: x, high: x, low: x, close: x }, ... ] }
- Return type
pandas.DataFrame
orjson
- Raises
ValueError β raised whenever any of the introduced arguments is not valid or errored.
IOError β raised if certificates object/file was not found or unable to retrieve.
RuntimeError β raised if the introduced certificate/country was not found or did not match any of the existing ones.
ConnectionError β raised if connection to Investing.com could not be established.
IndexError β raised if certificate historical data was unavailable or not found in Investing.com.
Examples
>>> data = investpy.get_certificate_historical_data(certificate='BNP Gold 31Dec99', country='france', from_date='01/01/2010', to_date='01/01/2019') >>> data.head() Open High Low Close Date 2010-01-04 77.15 77.15 77.15 77.15 2010-01-05 77.40 77.45 77.15 77.45 2010-01-06 78.40 78.40 78.40 78.40 2010-01-07 78.40 78.45 78.35 78.35 2010-01-08 77.95 78.10 77.95 78.10
-
investpy.certificates.
get_certificate_information
(certificate, country, as_json=False)ΒΆ This function retrieves fundamental financial information from the specified certificate. The retrieved information from the certificate can be valuable as it is additional information that can be used combined with OHLC values, so to determine financial insights from the company which holds the specified certificate.
- Parameters
certificate (
str
) β name of the certificate to retrieve information fromcountry (
country
) β name of the country from where the certificate is from.as_json (
bool
, optional) β optional argument to determine the format of the output data (dict
orjson
).
- Returns
The resulting
pandas.DataFrame
contains the information fields retrieved from Investing.com from the specified certificate; it can also be returned as adict
, if argument as_json=True.If any of the information fields could not be retrieved, that field/s will be filled with None values. If the retrieval process succeeded, the resulting
dict
will look like:certificate_information = { "Certificate Name": "XXXX", "Certificate Country": "XXXX", "Prev. Close": X.Y, "Todays Range": "X.Y - X.Y", "Leverage": "X:Y", "Open": X.Y, "52 wk Range": "X.Y - X.Y", "Strike Price": "XXXX", "Volume": X.Y, "Issue Date": "XXXX", "Issue Amount": "XXXX", "Average Vol. (3m)": X.Y, "Maturity Date": "dd/mm/yyyy", "1-Year Change": "X.Y%", "Asset Class": "XXXX" }
- Return type
pandas.DataFrame
ordict
- certificate_information
-
investpy.certificates.
get_certificate_recent_data
(certificate, country, as_json=False, order='ascending', interval='Daily')ΒΆ This function retrieves recent historical data from the introduced certificate from Investing.com. So on, the recent data of the introduced certificate from the specified country will be retrieved and returned as a
pandas.DataFrame
if the parameters are valid and the request to Investing.com succeeds. Note that additionally some optional parameters can be specified: as_json and order, which let the user decide if the data is going to be returned as ajson
or not, and if the historical data is going to be ordered ascending or descending (where the index is the date), respectively.- Parameters
certificate (
str
) β name of the certificate to retrieve recent data from.country (
str
) β name of the country from where the certificate is.as_json (
bool
, optional) β to determine the format of the output data, either apandas.DataFrame
if False and ajson
if True.order (
str
, optional) β to define the order of the retrieved data which can either be ascending or descending.interval (
str
, optional) β value to define the historical data interval to retrieve, by default Daily, but it can also be Weekly or Monthly.
- Returns
The function returns either a
pandas.DataFrame
or ajson
file containing the retrieved recent data from the specified certificate via argument. The dataset contains the OHLC values of the certificate.The returned data is case we use default arguments will look like:
Date || Open | High | Low | Close -----||------|------|-----|------- xxxx || xxxx | xxxx | xxx | xxxxx
but if we define as_json=True, then the output will be:
{ name: name, recent: [ { date: dd/mm/yyyy, open: x, high: x, low: x, close: x }, ... ] }
- Return type
pandas.DataFrame
orjson
- Raises
ValueError β raised if there was an argument error.
IOError β raised if certificates object/file was not found or unable to retrieve.
RuntimeError β raised if the introduced certificate does not match any of the indexed ones.
ConnectionError β raised if GET requests does not return 200 status code.
IndexError β raised if certificate information was unavailable or not found.
Examples
>>> data = investpy.get_certificate_recent_data(certificate='BNP Gold 31Dec99', country='france') >>> data.head() Open High Low Close Date 2020-07-09 146.4 146.8 145.95 145.95 2020-07-10 146.2 146.2 145.55 145.55 2020-07-13 145.6 145.6 145.45 145.45 2020-07-14 145.4 145.4 145.25 145.25 2020-07-15 144.9 145.1 144.70 144.95
-
investpy.certificates.
get_certificates
(country=None)ΒΆ This function retrieves all the data stored in certificates.csv file, which previously was retrieved from Investing.com. Since the resulting object is a matrix of data, the certificateβs data is properly structured in rows and columns, where columns are the certificate data attribute names. Additionally, country filtering can be specified, which will make this function return not all the stored certificates, but just the data of the certificates from the introduced country.
- Parameters
country (
str
, optional) β name of the country to retrieve all its available certificates from.- Returns
The resulting
pandas.DataFrame
contains all the certificateβs data from the introduced country if specified, or from every country if None was specified, as indexed in Investing.com from the information previously retrieved by investpy and stored on a csv file.So on, the resulting
pandas.DataFrame
will look like:country | name | full_name | symbol | issuer | isin | asset_class | underlying --------|------|-----------|--------|--------|------|-------------|------------ xxxxxxx | xxxx | xxxxxxxxx | xxxxxx | xxxxxx | xxxx | xxxxxxxxxxx | xxxxxxxxxx
- Return type
pandas.DataFrame
- certificates_df- Raises
ValueError β raised whenever any of the introduced arguments is not valid.
FileNotFoundError β raised if certificates.csv file was not found.
IOError β raised when certificates.csv file is missing or empty.
-
investpy.certificates.
get_certificates_dict
(country=None, columns=None, as_json=False)ΒΆ This function retrieves all the available certificates indexed on Investing.com, stored on certificates.csv. This function also allows the user to specify which country do they want to retrieve data from, or from every listed country; the columns which the user wants to be included on the resulting
dict
; and the output of the function will either be adict
or ajson
.- Parameters
country (
str
, optional) β name of the country to retrieve all its available certificates from.columns (
list
, optional) β names of the columns of the certificate data to retrieve <country, name, full_name, symbol, issuer, isin, asset_class, underlying>as_json (
bool
, optional) β value to determine the format of the output data which can either be adict
or ajson
.
- Returns
The resulting
dict
contains the retrieved data if found, if not, the corresponding fields are filled with None values.In case the information was successfully retrieved, the
dict
will look like:certificates_dict = { "country": "france", "name": "SOCIETE GENERALE CAC 40 X10 31DEC99", "full_name": "SOCIETE GENERALE EFFEKTEN GMBH ZT CAC 40 X10 LEVERAGE 31DEC99", "symbol": "FR0011214527", "issuer": "Societe Generale Effekten GMBH", "isin": "FR0011214527", "asset_class": "index", "underlying": "CAC 40 Leverage x10 NR" }
- Return type
dict
orjson
- certificates_dict- Raises
ValueError β raised whenever any of the introduced arguments is not valid.
FileNotFoundError β raised if certificates.csv file was not found.
IOError β raised when certificates.csv file is missing or empty.
-
investpy.certificates.
get_certificates_list
(country=None)ΒΆ This function retrieves all the available certificates indexed on Investing.com, already stored on certificates.csv. This function also allows the users to specify which country do they want to retrieve data from or if they want to retrieve it from every listed country; so on, a listing of certificates will be returned. This function helps the user to get to know which certificates are available on Investing.com.
- Parameters
country (
str
, optional) β name of the country to retrieve all its available certificates from.- Returns
The resulting
list
contains the retrieved data from the certificates.csv file, which is a listing of the names of the certificates listed on Investing.com, which is the input for data retrieval functions as the name of the certificate to retrieve data from needs to be specified.In case the listing was successfully retrieved, the
list
will look like:certificates_list = ['SOCIETE GENERALE CAC 40 X10 31DEC99', 'SG ZT CAC 40 x7 Short 31Dec99', ...]
- Return type
list
- certificates_list- Raises
ValueError β raised whenever any of the introduced arguments is not valid.
FileNotFoundError β raised if certificates.csv file was not found.
IOError β raised when certificates.csv file is missing or empty.
-
investpy.certificates.
get_certificates_overview
(country, as_json=False, n_results=100)ΒΆ This function retrieves an overview containing all the real time data available for the main certificates from a country, such as the names, symbols, current value, etc. as indexed in Investing.com. So on, the main usage of this function is to get an overview on the main certificates from a country, so to get a general view. Note that since this function is retrieving a lot of information at once, by default just the overview of the Top 100 certificates is being retrieved, but an additional parameter called n_results can be specified so to retrieve N results.
- Parameters
country (
str
) β name of the country to retrieve the certificates overview from.as_json (
bool
, optional) β optional argument to determine the format of the output data (pandas.DataFrame
orjson
).n_results (
int
, optional) β number of results to be displayed on the overview table (0-1000).
- Returns
The resulting
pandas.DataFrame
contains all the data available in Investing.com of the main certificates from a country in order to get an overview of it.If the retrieval process succeeded, the resulting
pandas.DataFrame
should look like:country | name | symbol | last | change_percentage | turnover --------|------|--------|------|-------------------|---------- xxxxxxx | xxxx | xxxxxx | xxxx | xxxxxxxxxxxxxxxxx | xxxxxxxx
- Return type
pandas.DataFrame
- certificates_overview- Raises
ValueError β raised if any of the introduced arguments is not valid or errored.
FileNotFoundError β raised when certificates.csv file is missing.
IOError β raised if data could not be retrieved due to file error.
RuntimeError β raised either if the introduced country does not match any of the listed ones or if no overview results could be retrieved from Investing.com.
ConnectionError β raised if GET requests does not return 200 status code.
-
investpy.certificates.
search_certificates
(by, value)ΒΆ This function searches certificates by the introduced value for the specified field. This means that this function is going to search if there is a value that matches the introduced one for the specified field which is the certificates.csv column name to search in. Available fields to search certificates are country, name, full_name, symbol, issuer, isin, asset_class, underlying.
- Parameters
by (
str
) β name of the field to search for, which is the column name which can be: country, name, full_name, symbol, issuer, isin, asset_class or underlying.value (
str
) β value of the field to search for, which is the value that is going to be searched.
- Returns
The resulting
pandas.DataFrame
contains the search results from the given query, which is any match of the specified value in the specified field. If there are no results for the given query, an error will be raised, but otherwise the resultingpandas.DataFrame
will contain all the available certificates that match the introduced query.- Return type
pandas.DataFrame
- search_result- Raises
ValueError β raised if any of the introduced parameters is not valid or errored.
FileNotFoundError β raised if certificates.csv file is missing.
IOError β raised if data could not be retrieved due to file error.
RuntimeError β raised if no results were found for the introduced value in the introduced field.