alvarobartt / investpy

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

Problem in finding ETFs with investpy #559

Open VGEng2 opened 2 years ago

VGEng2 commented 2 years ago

Hi @alvarobartt ,

and thank you for this very useful and complete python module.

I have just discovered it and easily starting using and enjoying it. Thank you again for this.

As part of the exercise I was trying to retrieve ETFs data, which I understand can be done only looking by name. To be sure to get the right name I am using the search_quotes tools as, such that, given the ETF symbol I find the name as reported by Investing.com:

ETF = investpy.search_quotes(text='UUP', products=['etfs'], countries=['united states'], n_results=1)

than I try to retrieve the historical data:

df = investpy.get_etf_historical_data(etf=ETF.name, country='United States', from_date='01/01/2020',
to_date='01/05/2022', order='descending', interval='weekly')

the first output is given my print (ETF):

{"id_": 37471, "name": "Invesco DB US Dollar Index Bullish Fund", "symbol": "UUP", "country": "united states", "tag": "/etfs/powershares-db-usd-index-bullish", "pair_type": "etfs", "exchange": "NYSE"}

and then when the data retrieving is processed I got the following error:

RuntimeError: ERR#0019: etf invesco db us dollar index bullish fund not found, check if it is correct.

As alternative option, I have tried as follows:

df=ETF.retrieve_historical_data(from_date='01/01/2020', to_date='01/05/2022')

By following this way it works, however I can select the timeframe (i.e., daily, weekly, monthly) as well as I can't select the data order (i.e., ascending or descending).

So said, I have the following questions:

1) is it possible to find for ETF searching by symbols? 2) is it possible to include in to the retrieve_historical_data also the other options like, timeframe and ordering?

Thank you in advanced for your support.

Kind regards