investpy.search
¶
-
investpy.search.
search_events
(text, importances=None, countries=None, n_results=None)¶ TODO
-
investpy.search.
search_quotes
(text, products=None, countries=None, n_results=None)¶ This function will use the Investing.com search engine so to retrieve the search results of the introduced text. This function will create a
list
ofinvestpy.utils.search_obj.SearchObj
class instances, unless n_results is set to 1, where just a singleinvestpy.utils.search_obj.SearchObj
will be returned.Those class instances will contain the search results so that they can be easily accessed and so to ease the data retrieval process since it can be done calling the methods self.retrieve_recent_data() or self.retrieve_historical_data(from_date, to_date) from each class instance, which will fill the historical data attribute, self.data. Also the information of the financial product can be retrieved using the function self.retrieve_information(), that will also dump the information in the attribute self.information; the technical indicators can be retrieved using self.retrieve_technical_indicators() dumped in the attribute self.technical_indicators; the default currency using self.retrieve_currecy() dumped in the attribute self.default_currency.
- Parameters
text (
str
) – text to search in Investing.com among all its indexed data.products (
list
ofstr
, optional) – list with the product type filter/s to be applied to search result quotes so that they match the filters. Possible products are: indices, stocks, etfs, funds, commodities, currencies, cryptos, bonds, certificates and fxfutures, by default this parameter is set to None which means that no filter will be applied, and all product type quotes will be retrieved.countries (
list
ofstr
, optional) – list with the country name filter/s to be applied to search result quotes so that they match the filters. Possible countries can be found in the docs, by default this paremeter is set to None which means that no filter will be applied, and quotes from every country will be retrieved.n_results (
int
, optional) – number of search results to retrieve and return.
- Returns
The resulting
list
ofinvestpy.utils.search_obj.SearchObj
will contained the retrieved financial products matching the introduced text if found, otherwise a RuntimeError will be raised, so as to let the user know that no results were found for the introduced text. But note that if the n_results value is equal to 1, a single value will be returned, instead of a list of values.- Return type
list
ofinvestpy.utils.search_obj.SearchObj
orinvestpy.utils.search_obj.SearchObj
- Raises
ValueError – raised whenever any of the introduced parameter is not valid or errored.
ConnectionError – raised whenever the connection to Investing.com failed.
RuntimeError – raised when there was an error while executing the function.
-
class
investpy.utils.search_obj.
SearchObj
(id_, name, symbol, tag, country, pair_type, exchange)¶ Class which contains each search result when searching data in Investing.com.
This class contains the search results of the Investing.com search made with the function call investpy.search_quotes(text, products, countries, n_results) which returns a
list
of instances of this class with the formatted retrieved information. Additionally, data can either be retrieved or not including both recent and historical data, which will be included in the SearchObj.data attribute when calling either SearchObj.retrieve_recent_data() or SearchObj.retrieve_historical_data(from_date, to_date), respectively.-
id_
¶ ID value used by Investing.com to retrieve data.
- Type
int
-
name
¶ name of the retrieved financial product.
- Type
str
-
symbol
¶ symbol of the retrieved financial product.
- Type
str
-
tag
¶ tag (which is the Investing.com URL) of the retrieved financial product.
- Type
str
-
country
¶ name of the country from where the retrieved financial product is.
- Type
str
-
pair_type
¶ type of retrieved financial product (stocks, funds, etfs, etc.).
- Type
str
-
exchange
¶ name of the stock exchange of the retrieved financial product.
- Type
str
- Extra Attributes:
- data (
pandas.DataFrame
): recent or historical data to retrieve from the current financial product, generated after calling either self.retrieve_recent_data or self.retrieve_historical_data().
- info (
dict
): contains the information of the current financial product, generated after calling the self.retrieve_information() function.
- data (
-
__eq__
(other)¶ Return self==value.
-
__hash__
()¶ Return hash(self).
-
__init__
(id_, name, symbol, tag, country, pair_type, exchange)¶ Initialize self. See help(type(self)) for accurate signature.
-
__str__
()¶ Return str(self).
-
__weakref__
¶ list of weak references to the object (if defined)
-
retrieve_currency
()¶ Class method used to retrieve the default currency from the class instance of any financial product.
This method retrieves the default currency from Investing.com of the financial product of the current class instance. This method uses the data previously retrieved from the investpy.search_quotes(text, products, countries, n_results) function search results to build the request that it is going to be sent to Investing.com so to retrieve and parse the information, since the product tag is required.
- Returns
This method retrieves the default currency from the current class instance of a financial product from Investing.com.
- Return type
str
- default_currency- Raises
ConnectionError – raised if connection to Investing.com could not be established.
RuntimeError – raised if there was any problem while retrieving the data from Investing.com.
-
retrieve_historical_data
(from_date, to_date)¶ Class method used to retrieve the historical data from the class instance of any financial product.
This method retrieves the historical data from Investing.com of the financial product of the current class instance on the specified date range, so it fills the SearchObj.data attribute with the retrieved
pandas.DataFrame
. This method uses the previously filled data from the investpy.search_quotes(text, products, countries, n_results) function search results to build the request that it is going to be sent to Investing.com so to retrieve and parse the data.- Parameters
from_date (
str
) – date from which data will be retrieved, specified in dd/mm/yyyy format.to_date (
str
) – date until data will be retrieved, specified in dd/mm/yyyy format.
- Returns
This method retrieves the historical data from the current class instance of a financial product from Investing.com. This method both stores retrieved data in self.data attribute of the class instance and it also returns it as a normal function will do.
- Return type
pandas.DataFrame
- data- Raises
ValueError – raised if any of the introduced parameters was not valid or errored.
RuntimeError – raised if there was any error while retrieving the data from Investing.com.
-
retrieve_information
()¶ Class method used to retrieve the information from the class instance of any financial product.
This method retrieves the information from Investing.com of the financial product of the current class instance, so it fills the SearchObj.info attribute with the retrieved
dict
. This method uses the previously retrieved data from the investpy.search_quotes(text, products, countries, n_results) function search results to build the request that it is going to be sent to Investing.com so to retrieve and parse the information, since the product tag is required.- Returns
This method retrieves the information from the current class instance of a financial product from Investing.com. This method both stores retrieved information in self.information attribute of the class instance and it also returns it as a normal function will do.
- Return type
dict
- info- Raises
ConnectionError – raised if connection to Investing.com could not be established.
RuntimeError – raised if there was any problem while retrieving the data from Investing.com.
-
retrieve_recent_data
()¶ Class method used to retrieve the recent data from the class instance of any financial product.
This method retrieves the recent data from Investing.com of the financial product of the current class instance, so it fills the SearchObj.data attribute with the retrieved
pandas.DataFrame
. This method uses the previously filled data from the investpy.search_quotes(text, products, countries, n_results) function search results to build the request that it is going to be sent to Investing.com so to retrieve and parse the data.- Returns
This method retrieves the recent data from the current class instance of a financial product from Investing.com. This method both stores retrieved data in self.data attribute of the class instance and it also returns it as a normal function will do.
- Return type
pandas.DataFrame
- data
-
retrieve_technical_indicators
(interval='daily')¶ Class method used to retrieve the technical indicators from the class instance of any financial product.
This method retrieves the technical indicators from Investing.com for the financial product of the current class instance, to later put in into the SearchObj.technical_indicators attribute. This method uses the previously retrieved data from the investpy.search_quotes(text, products, countries, n_results) function search results to build the request that it is going to be sent to Investing.com so to retrieve and parse the technical indicators, since the product id is required.
- Parameters
interval (
str
, optional) – time interval of the technical indicators’ calculations, available values are: 5mins, 15mins, 30mins, 1hour, 5hours, daily, weekly and monthly. Note that for funds just the intervals: daily, weekly and monthly are available.- Returns
This method retrieves the technical indicators from the current class instance of a financial product from Investing.com. This method not just stores retrieved technical indicators table into self.technical_indicators but it also returns it as a normal function will do.
- Return type
pd.DataFrame
- technical_indicators- Raises
ValueError – raised if any of the input parameters is not valid.
ConnectionError – raised if connection to Investing.com could not be established.
RuntimeError – raised if there was any problem while retrieving the data from Investing.com.
-