alvarobartt / investpy

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

inv.search_funds is not finding new funds #325

Closed lucas-leme closed 3 years ago

lucas-leme commented 3 years ago

I was trying to get the historical data of this fund: https://www.investing.com/funds/br025jctf005

But the investpy does not find it.

inv.search_funds(by='symbol', value='0P0001I7OT')

Error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-139-b733d00b40f2> in <module>
----> 1 inv.search_funds(by='symbol', value='0P0001I7OT')

~/miniconda3/envs/general/lib/python3.9/site-packages/investpy/funds.py in search_funds(by, value)
    969 
    970     if len(search_result) == 0:
--> 971         raise RuntimeError('ERR#0043: no results were found for the introduced ' + str(by) + '.')
    972 
    973     search_result.drop(columns=['matches'], inplace=True)

RuntimeError: ERR#0043: no results were found for the introduced symbol.
alvarobartt commented 3 years ago

Hi @lucas-leme, if you check the investpy.search_funds() documentation you will see that the function just searches between the funds stored in the static file resources/funds.csv, which means that this function is not searching new funds.

In order to do so, just use the investpy.search_quotes() function, this is a simple example that may be useful to you:

import investpy

search_result = investpy.search_quotes(text='0P0001I7OT', products=['funds'], n_results=1)

recent_data = search_result.retrieve_recent_data()
historical_data = search_result.retrieve_historical_data(from_date='01/01/2020', to_date='01/01/2021')
information = search_result.retrieve_information()

Let me know whether this worked for you or not! :+1:

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

:pushpin: Note. In the recent investpy versions, the investpy.search_quotes() function just returns one search result whenever the value for n_results is 1, which means that instead of expecting a list of SearchObj class instances, you should just expect one, as shown in the example presented above.

lucas-leme commented 3 years ago

Hi @alvarobartt, it worked for me! Thank you very much. I didn't know about the investpy.search_quotes() module, it will help me a lot.

rgno1 commented 2 years ago

Hi Alvaro!

It is possible to increase decimal places from 3 to 8? Not sure if Investing.com doesn't record with full precision or if its possible to get the full number.