Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No currency provided when using investpy.search_quotes() and then .retrieve_historical_data #181

Closed
Fetix opened this issue Jun 22, 2020 · 4 comments
Assignees
Labels
improvement Something needs to be improved

Comments

@Fetix
Copy link

Fetix commented Jun 22, 2020

H there,
really, really like investpy :-))
I recently asked investing to add an ETF (IE00BFNM3P36) (which they did).
For this one I can't retrieve information using get_etf_historical_data . Your proposed workaround (#148) using the developer version of investpy and investpy.search_quotes() and .retrieve_historical_data works to get the data however the course data is missing their currency (which get_etf_historical_data provides if it finds the product of interest)

  • Will I be able to retrieve the new ETF's data using get_etf_historical_data after the etfs.csv has been updated the next time?

  • I really like that using search_quotes() and retrieve_historical_data from the developer version does not require you to run different commands to retrieve data for etfs, stocks, .... but is there a way to obtain the currency information? As far as I see neither search_quotes() nor .retrieve_historical_data return it. This would be awesome.

Best,
Fetix

@Fetix Fetix closed this as completed Jun 22, 2020
@Fetix
Copy link
Author

Fetix commented Jun 22, 2020

Closed: Added a comment to #172

@alvarobartt alvarobartt self-assigned this Jun 9, 2021
@alvarobartt alvarobartt added the improvement Something needs to be improved label Jun 9, 2021
@alvarobartt alvarobartt added this to the investpy v1.0.7 milestone Jun 9, 2021
@alvarobartt alvarobartt reopened this Jun 9, 2021
@alvarobartt
Copy link
Owner

Hi again @Fetix! 🤗

I've already implemented a function to retrieve the default currency of every SearchObj after calling investpy.search_quotes so that you can just use the following piece of code:

>>> import investpy
>>> search_result = investpy.search_quotes(text='apple', n_results=1)
>>> print(search_result)
{"id_": 6408, "name": "Apple Inc", "symbol": "AAPL", "country": "united states", "tag": "/equities/apple-computer-inc", "pair_type": "stocks", "exchange": "NASDAQ"}
>>> currency = search_result.retrieve_currency()
>>> print(currency)
USD
>>> print(search_result.default_currency)
USD

Also see below that it's pretty simple but efficient and the elapsed time to retrieve the currency is less than 300ms, which is something nice too!

/workspace/investpy $ time python -c "import investpy;data = investpy.search_quotes('apple', n_results=1);curr = data.retrieve_currency()"

real    0m1.384s
user    0m0.841s
sys     0m0.736s
/workspace/investpy $ time python -c "import investpy;data = investpy.search_quotes('apple', n_results=1)"

real    0m1.094s
user    0m0.824s
sys     0m0.871s

@alvarobartt
Copy link
Owner

It seems that as it happened before with SearchObj.retrieve_information, as described in #395, Investing.com has different HTML templates for the stocks, since the stocks/equities pages are already using the new templates, all the other financial products are still using the old one, so we need to define a way to either use one parser or another based on the product type 😖

Hopefully the current version I developed for SearchObj.retrieve_information can be re-used as it should be consistent to new changes and easy to update to adapt to the new changes on the different financial product HTMLs 👍

@alvarobartt
Copy link
Owner

Hi @Fetix, the new release is already out! 🔥

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! 👍

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Something needs to be improved
Projects
None yet
Development

No branches or pull requests

2 participants