alvarobartt / investpy

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

Bug in `SearchObj.retrieve_information` due to Investing.com updates #395

Closed alvarobartt closed 3 years ago

alvarobartt commented 3 years ago

Currently there's a bug in SearchObj.retrieve_information method, that has been spotted recently as this function was not included in the tests so we didn't realise that the Investing.com information changed recently and the function was not working :confounded:

So on, we need to fix this function with the new Investing.com HTML information!

alvarobartt commented 3 years ago

This has already been fixed and now the name of the values is different, since we are using the same identifiers as Investing.com is using internally, so as to have simpler names in camelCase rather than the previous names with dots, commas, spaces, etc.

Here's a comparison between the new updated method in SearchObj.retrieve_information versus the old one in investpy.get_stock_information both for the same stock so that the comparison is 1:1

import investpy
search_result = investpy.search_quotes(text='BBVA', products=['stocks'], countries=['united states'], n_results=1)
search_result .retrieve_information()
print(search_result.information)
{
   "prevClose":6.36,
   "dailyRange":"6.29-6.38",
   "revenue":17270000000,
   "open":6.32,
   "weekRange":"2.49-6.47",
   "eps":1.08,
   "volume":1376877,
   "marketCap":42270000000,
   "dividend":"0.28(4.47%)",
   "avgVolume":2401747,
   "ratio":5.88,
   "beta":1.42,
   "oneYearReturn":"89.02%",
   "sharesOutstanding":6653533748,
   "nextEarningDate":"30/07/2021"
}
import investpy
information = investpy.get_stock_information(stock='BBVA', country='united states', as_json=True)
print(information)
{
   "Stock Symbol":"BBVA",
   "Prev. Close":6.36,
   "Todays Range":"6.29-6.38",
   "Revenue":17270000000.0,
   "Open":6.32,
   "52 wk Range":"2.49-6.47",
   "EPS":1.08,
   "Volume":1376877.0,
   "Market Cap":42270000000.0,
   "Dividend (Yield)":"0.28(4.47%)",
   "Average Vol. (3m)":2401747.0,
   "P/E Ratio":5.88,
   "Beta":1.42,
   "1-Year Change":"89.02%",
   "Shares Outstanding":6653533748.0,
   "Next Earnings Date":"30/07/2021"
}
alvarobartt commented 3 years ago

The build is still failing since Investing.com updated the HTML just for some financial products, which is causing an inconsistency while scraping the information, but it'll be fixed ASAP!

alvarobartt commented 3 years ago

Hi everyone, 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: