alvarobartt / investpy

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

Retrieving all stocks from an index given #447

Open javibel opened 2 years ago

javibel commented 2 years ago

Is there a method to achieve this goal? I need to know how many and which are all the stocks in an index given, for instance DAX... Thank you for your work!

alvarobartt commented 2 years ago

Hi @javibel currently there's not a function to do so, but I'd suggest you use the investpy.search_quote() function so as to look for stocks based on an index, so that the input text should be the index name while the product list to filter by should just contain the stocks. Hope this helps you this time! :hugs:

Anyway, could you please share the Investing.com URL for an index listing with all the stocks in there? So that I can see whether this is a feature that I can develop or not. Thanks! :+1:

javibel commented 2 years ago

I think you speak english aren't you?, in that case We should continue in spanish if you don't mind... The fact is that your suggestion above doesn't work, I'm afraid. I paste below an example of result of: "search_result = investpy.search_quotes(text='Xetra', products=['stocks'], countries=['germany'], n_results=1)"

search_result = investpy.search_quotes(text='Xetra', products=['stocks'],
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/investpy/search.py", line 171, in search_quotes
    raise RuntimeError("ERR#0093: no results found on Investing.com for the introduced query.")
RuntimeError: ERR#0093: no results found on Investing.com for the introduced query.

Here you have a link of Spain index with all its components: https://es.investing.com/indices/spain-35-components?cid=26491

Thank you again!