Closed Heractos closed 3 years ago
Hi @Heractos, sure! I'll include it later this week for the upcoming release :fire: Thanks for the proposal!
Hi again @Heractos! :hugs:
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
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 :confounded:
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 :+1:
Hi @Heractos, 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:
Could you please add Currency to SearchObj.py -> def _data_retrieval(self, product, headers, params). This feature would be extremely helpful and from what I see, it should be an easy problem to fix. Thank you so much in advance.