alvarobartt / investpy

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

Stocks retrieval getting wrong symbols #299

Open Jihad opened 3 years ago

Jihad commented 3 years ago

Hello there,

I'm using both: inpy.get_stock_recent_data("2222", 'Saudi Arabia')

and inpy.get_stock_historical_data(stock, country, "from_date", "to_date", as_json=False, order='ascending')

For Middle east market, especially country="Saudi Arabia"

I noticed there are multiple stocks getting this error: Traceback (most recent call last): File "/Users/jihad/Dev/miniconda3/envs/stocksData/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3437, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-16-ba0abfc68973>", line 1, in <module> inpy.get_stock_recent_data(str(2222), 'Saudi Arabia') File "/Users/jihad/Dev/miniconda3/envs/stocksData/lib/python3.8/site-packages/investpy/stocks.py", line 265, in get_stock_recent_data raise RuntimeError("ERR#0018: stock " + stock + " not found, check if it is correct.") **RuntimeError: ERR#0018: stock 2222 not found, check if it is correct.**

To debug this, I used: inpy.get_stocks(country='Saudi Arabia')

and the full list count was equivalent to Saudi Arabia investing.com page

But, some companies have wrong symbols or empty ones, two examples: Baazeem Trading Co investing.com page --> but in the list it has 9503 symbol, not sure why? Also ARAMCO investing.com page --> but in the list its ARAM symbol, not sure why? with empty full name & isin fields.

Is it a bug? or i'm doing something wrong? most others works fine.

alvarobartt commented 3 years ago

Hi @Jihad! Thank you for spotting this issue 👍🏻 It's due to the fact that the static data may not be up-to-date, and updating it is really tricky, so in the meantime, I encourage you to use the investpy.search_quotes() functionality which retrieves the most updated data as it's using Investing.com search engine.

More information available at: https://github.com/alvarobartt/investpy/wiki/investpy.search_quotes()