'Python yfinance startdate enddate not match
I am trying to get the exact one-day stock data from yfinance, but I found the date may take a day before the startdate and enddate in the requests.
The code I have used:
result = yf.download(tickers = 'aapl', start = '2022-03-10',end = '2022-03-10', prepost = True, progress=False)
The above will return the data on 2022-03-09. But what I want is the data on the 2022-03-10.
Solution 1:[1]
In that case, you can retrieve the data for two days and just remove one row.
result = yf.download(tickers = 'aapl', start = '2022-03-10',end = '2022-03-11', prepost = True, progress=False)
result.drop(index="2022-03-09", inplace=True)
print(result)
Open High ... Adj Close Volume
Date ...
2022-03-10 160.199997 160.389999 ... 158.520004 105342000
[1 rows x 6 columns]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kevin Choon Liang Yew |
