Closed zinovevvv closed 3 years ago
Hi @Mrziiz, thanks for spotting this issue!
You are indeed right, I should also include the currency value in the investpy.get_stock_financial_summary
function, since it's not the same as the one retrieved for the stock... This seems to be an inconsistency from Investing.com as the user should expect the data on the same page to use the same currency among all the displayed data I guess... 😖
Anyway, thanks for spotting this, I'll solve this bug ASAP! :hugs:
Hi again @Mrziiz! :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
Even though the issue with the currency used for the financials is still not solved, since I need to figure out how to include that value, since it's usually "in Millions of X (with some exception)" so it may not be as straight forward as multiplying the values per 1M and then setting that currency as the default one...
Anyway, you can already retrieve the default currency for every financial product from the result of investpy.search_quotes()
, that as you may know it internally uses the Investing.com search engine.
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 @Mrziiz, 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:
Can u help me with this issue, when I get information about market cup and others I can understand what the currency in use with search_stocks in column 'currency':
It's true, currencies are same!
But when I used get_stock_financial_summary i found that currency was not same, and there was no place where I could got it:
I thank that this numbers was in USD but they was in GBP: