alvarobartt / investpy

Financial Data Extraction from Investing.com with Python
https://investpy.readthedocs.io/
MIT License
1.59k stars 375 forks source link

US Index data not available #370

Closed plutoBase closed 3 years ago

plutoBase commented 3 years ago

Just doing some very simple testing trying to get data out for an index

df = investpy.get_index_recent_data(index='Dow Jones Software', country='United States') print(df.head())

the symbol is: DJUSSW

Can you help me to understand the problem, please?

Many thanks

alvarobartt commented 3 years ago

Hi @plutoBase, some financial products are not available among the investpy static files (CSVs) which means that either the financial products were not available when I generated those files from Investing.com, the Investing.com indexing does not work as expected so some financial products are not "retrievable".

The solution to this both from the web and using investpy is to use the search engine, to do so using this package you should do this:

>>> import investpy
>>> investpy.__version__
'1.0.6'

>>> search_result = investpy.search_quotes(text='DJUSSW', products=['indices'], countries=['united states'], n_results=1)
{"id_": 20094, "name": "Dow Jones Software", "symbol": "DJUSSW", "country": "united states", "tag": "/indices/dj-software", "pair_type": "indices", "exchange": "NYSE"}

# You can now retrieve either the recent or historical data and the financial product information as it follows
>>> recent_data = search_result.retrieve_recent_data()
>>> historical_data = search_result.retrieve_historical_data(from_date='01/01/2020', to_date='01/01/2021')
>>> information = search_result.retrieve_information()

I've checked the piece of code above and it works like charm, so feel free to use investpy.search_quotes() instead of the other functions as you may run into missing data errors due to the problems I mentioned above!

To further explore the functionality of investpy.search_quotes() please check [Wiki - investpy.search_quotes()](https://github.com/alvarobartt/investpy/wiki/investpy.search_quotes())

:pushpin: Make sure that you are using the latest investpy version! investpy v1.0.6

plutoBase commented 3 years ago

Many thanks!