Closed dapaexp closed 3 years ago
Hi @dapaexp, are you using the latest investpy
version? As I think that you may be using investpy v1.0.5
, where investpy.search_quotes(..., n_results=1)
was returning a list of SearchObj
class instances rather than just one instance.
Also, note that for consistency you should surround the call to investpy.search_quotes()
with a try: ... except Exception as e: ...
code block so as to make sure that the ISIN you are looking for was found.
For further information feel free to check whether those ISINs are available at Investing.com either manually from the website search engine, or automatically handling the exceptions and printing the not found, wrong, failing, etc. ISIN codes!
Check the investpy
version as:
>>> import investpy
>>> investpy.__version__
1.0.6
If you have another version, update the package with the following command:
pip install git+https://github.com/alvarobartt/investpy.git@master
Great! Thank you! Finally I managed to write it like this..
`#isins_list = ['DE0002635265','DE0002635XYZ','DE0002635307','DE0005933931','DE000A0D8Q07','IE00B23D8S39','FR0010655746','FR0010655761','IE00B7LW6Y90'] isins_list = ['DE0002635265','DE000263RUCK','DE0002635307','DE0005933931','DE000A0PPPPRT','IE00B23D8S39','FR0010655746','mariamaria','IE00B7LW6Y90'] isins=pd.Series(isins_list) notfoundisin=pd.Series(0, index=np.arange(len(isins_list)), dtype=str) not_hist=pd.Series(0, index=np.arange(len(isins_list)), dtype=str) results=dict() information=dict() j=0
for isin in isins: try: search_result = investpy.search_quotes(text=isin, products=['etfs'], countries=['italy'], n_results=1) except: notfoundisin.iat[j]=isin else: try: results[isin] = search_result.retrieve_historical_data(from_date='04/05/2021', to_date='06/05/2021') except: not_hist.iat[j]=isin j=j+1
results`
Hi, I'm trying to extract all the Italian ETFs searching by ISIN
`isins_list = ['DE0002635265','DE0002635299',......1134 ISIN HERE......... ] isins=pd.Series(isins_list) results=dict() information=dict()
for isin in isins: search_result = investpy.search_quotes(text=isin, products=['etfs'], countries=['italy'], n_results=1) results[isin] = search_result.retrieve_historical_data(from_date='04/05/2021', to_date='06/05/2021')
results`
But i get this error: `--------------------------------------------------------------------------- AttributeError Traceback (most recent call last)