alvarobartt / investpy

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

OHLCV data for XOG (United States) is not accurate #459

Closed martinemilander closed 2 years ago

martinemilander commented 2 years ago

Hi

OHLCV data for XOG (United States) is not accurate. Closing price on 2021-Oct-20 was 65.00 USD but I get this when I download using this command:

investpy.get_stock_historical_data(stock='XOG', country='united states', from_date='01/01/1950', to_date='21/10/2021')

              Open    High     Low   Close   Volume Currency
Date                                                        
2016-10-13  21.790  21.940  21.270  21.400  3358110      USD
2016-10-14  21.580  21.940  21.010  21.780  1378186      USD
2016-10-17  22.100  22.100  21.100  21.510  1017554      USD
2016-10-18  21.800  21.870  21.240  21.710   668910      USD
2016-10-19  21.700  23.120  21.420  22.280  1857740      USD
...            ...     ...     ...     ...      ...      ...
2021-01-12   0.060   0.060   0.045   0.050  1024276      USD
2021-01-13   0.050   0.058   0.049   0.057  1711876      USD
2021-01-14   0.059   0.090   0.052   0.080  5798181      USD
2021-01-15   0.087   0.095   0.060   0.060  5044202      USD
2021-01-19   0.065   0.069   0.058   0.062  2436468      USD

[1072 rows x 6 columns]
martinemilander commented 2 years ago

There appears to be a wrong ISIN for XOG. The correct one is US30227M3034. But it doesn't solve the problem by correcting in the "stocks.csv" file under resources.

alvarobartt commented 2 years ago

Hi @martinemilander thanks for reporting this issue!

Regarding the static files of investpy just to let you know that those are not too reliable, as those need to be updated on an e.g. monthly basis, but updating those is not as easy as it seems. This is why I'm planning to deprecate the static files from investpy so that just the Investing.com search engine is used so as to ensure that the data is always up-to-date and aligned with the one available at Investing.com.

So on, the recommended way right now to download data from financial products is as it follows:

import investpy

search_result = investpy.search_quotes(text="XOG", countries=["United States"], products=["stocks"], 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")

I hope this piece of code was useful to you! :hugs:

alvarobartt commented 2 years ago

📌 More information on investpy.search_quotes available at: