alvarobartt / investpy

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

investpy.technical_indicators could not find existing ETF #392

Closed mrtuborg closed 3 years ago

mrtuborg commented 3 years ago

Thank you for this great library.

I was trying to find some tech indicators for one of the etfs (I have checked this ETF on the site before using it with your library).

isin = 'IE00BDQZ5152'
item = investpy.search.search_quotes(isin)[0]
print("Ticker: " + item.name)

investpy.technical_indicators(name=item.name,
                                    product_type='etf',
                                    country = item.country,
                                    interval = 'daily')

so here I have following values item.symbol = 'ICBU' item.country = 'united kingdom' item.name = 'iShares $ Intermediate Credit Bond UCITS ETF USD (Dist)'

But I am getting the following error message:

  File "/usr/local/lib/python3.9/site-packages/investpy/technical.py", line 124, in technical_indicators
    raise ValueError("ERR#0122: introduced name does not exist in the introduced country (if required).")
ValueError: ERR#0122: introduced name does not exist in the introduced country (if required).

The first question why not use ISIN, which is unique across the whole data set, may be with extending it with exchange name (ISIN could exists across different exchange markets, but indeed this is the same paper)

And secondly, what is wrong with my request? Probably I can find a bug and try to fix it with my programming skills, then, where should I start to reduce the search area?

alvarobartt commented 3 years ago

Hi @mrtuborg thanks for your kind words! :hugs:

Yes, indeed there's a misalignment between the static files (used by all the investpy functions) and the results provided by the Investing.com search engine through investpy.search_quotes, so what you are trying above won't work unless the exact ETF that you are looking for is 1:1 aligned with any of the indexed ones in the static files...

This is a common investpy issue, as it's quite hard to keep the static files updated and with all the information provided by Investing.com...

So later this week I'll release a new version where you can just use the following piece of code:

import investpy

isin = 'IE00BDQZ5152'
search_result = investpy.search_quotes(text=isin, n_results=1)

indicators = search_result.retrieve_technical_indicators()
alvarobartt commented 3 years ago

Note that the latest investpy version is v1.0.6, which changed the investpy.search_quotes functionality and fixed some bugs/issues there, so currently the recommended way to use it is:

import investpy

isin = 'IE00BDQZ5152'
search_result = investpy.search_quotes(text=isin, n_results=1)

So that you just retrieve the first result setting n_results=1, because the other way around you were retrieving all the matches (in this case maybe a few but if you look for e.g. APPLE the request may take too long whenever you just want the first occurrence, the top one).

For more information feel free to contact me! :+1:

alvarobartt commented 3 years ago

Hi @mrtuborg I'm glad to inform you that this feature has already been developed in the dev branch as part of the current milestone before the investpy v1.0.7 release, so this feature will be available later this weekend so you just need to stay tuned for updates :fire:

The intended usage of this new functionality integrated with investpy.search_quotes() will be as it follows:

>>> import investpy
>>> data = investpy.search_quotes('bbva', products=['funds'], n_results=1)
>>> tech = data.retrieve_technical_indicators()
>>> tech
              indicator           signal     value
0               RSI(14)              buy   61.0810
1            STOCH(9,6)          neutral   48.7880
2          STOCHRSI(14)       overbought  100.0000
3           MACD(12,26)          neutral    0.0000
4               ADX(14)       overbought  100.0000
5           Williams %R       overbought    0.0000
6               CCI(14)       overbought  215.0252
7               ATR(14)  less_volatility    0.0053
8        Highs/Lows(14)              buy    0.0172
9   Ultimate Oscillator       overbought   72.1490
10                  ROC              buy    2.2470
11  Bull/Bear Power(13)              buy    0.0316

Note that the previous function investpy.technical_indicators() was retrieving those indicators based on the static files information, that is a little bit outdated, so using investpy.search_quotes() you'll get the latest information for every single financial product available in Investing.com. Also note that previously the column containing the technical indicator name was named 'technical_indicator' whilst now it's been renamed to 'indicator'.

Thanks for your support! :+1:

alvarobartt commented 3 years ago

Hi @mrtuborg, the new release is already out! :fire:

You can already install it using either pip install investpy==1.0.7 or just update the current version that you are using with pip install investpy --upgrade. Thanks a lot for your support! :+1:

For more information about this new release, you should check investpy v1.0.7 Release :balloon: