alvarobartt / investpy

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

Error when trying to search for Fund. Funds exists on investing.com, but library says it doesn't. #287

Open jpcf opened 3 years ago

jpcf commented 3 years ago

Whenever I try to search for the fund "PostFinance Pension 100", either by using investpy.funds.search_funds(by='name', value='PostFinance Pension 100')`

or even by its isin investpy.funds.search_funds(by='isin', value='CH0484781684') I get the error RuntimeError: ERR#0019: fund postfinance pension 100 not found, check if it is correct.

However, this fund does exist on investing.com, as you can see for yourself in this link: https://www.investing.com/funds/ch0484781684

Coincidently, a similar fund called "PostFinance Pension 45" works with these functions. For reference, I get the same error when I use the function investpy.get_fund_historical_data

alvarobartt commented 3 years ago

Hi @jpcf! Thanks for reporting this issue, currently we have a lot of problems regarding the missing data as those CSVs are generated with a script that relies on Investing.com which means that if there's an indexing problem on their side we cannot solve it 😩

Anyway, a while ago I created a support function for the missing financial products (missing on the static CSV files but available in Investing.com), which is the investpy.search_quotes() function, here's an example of its usage and a brief explanation: https://github.com/alvarobartt/investpy/wiki/investpy.search_quotes()

Also feel free to check the official docs at: https://investpy.readthedocs.io/_api/search.html

alvarobartt commented 3 years ago

AFAIK in your case, the code should be something similar to:

import investpy

search_results = investpy.search_quotes(text='CH0484781684', n_results=1)
print(search_results[0])
data = search_results[0].get_recent_data()
print(data)

DeprecationWarning ⚠️: in the investpy v1.0.3 release that will be out later this week, there will be a minor change, which is that in case you specify just n_results=1, you will receive a value, not a list of values.

jpcf commented 3 years ago

Thanks, I will try this workaround! ;)

alvarobartt commented 3 years ago

Hope this was useful to you! Remember to star the repo, follow me here and on Twitter at https://twitter.com/alvarobartt so as to get notified of all the updates and projects I'm working on! ⭐ :octocat: