-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yf.download() returning incorrect index #2101
Comments
A quick fix I found is to rename the columns: data.index.name = 'Date' |
I can't reproduce integer index - is that the problem?
|
Integer index wasnt the problem for me, it was the ticker index. his PR solves the issue. |
If you are only fetching one symbol, why not use |
The output is different from 0.2.47 to 0.2.48, I have downgraded to 0.2.47 and the output looks good. This is the output of 0.2.47.
As you can see, the header/index from 0.2.48 is different with: |
I wasn't aware that I can do the same using yf.Ticker('SPY').history(). I upgraded to 0.2.49 and sees that Tracing the code a bit and based on my limited understand, yf.download("SPY") has wrapper to handle multiple tickers so yf.Ticker('SPY').history() looks like is more efficient for one ticker case. I will modify my code to use yf.Ticker('SPY').history(). Thanks for your help. |
Describe bug
yf.download() returning incorrect index
Simple code that reproduces your problem
import yfinance as yf
data = yf.download('SPY')
data.head()
Debug log
DEBUG Entering download()
DEBUG Disabling multithreading because DEBUG logging enabled
DEBUG Entering history()
DEBUG Entering history()
DEBUG SPY: Yahoo GET parameters: {'period1': '1925-11-20 12:49:42-05:00', 'period2': '2024-10-26 13:49:42-04:00', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering get()
DEBUG Entering _make_request()
DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/SPY
DEBUG params={'period1': -1392099018, 'period2': 1729964982, 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = 'basic'
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG reusing cookie
DEBUG reusing crumb
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=200
DEBUG Exiting _make_request()
DEBUG Exiting get()
DEBUG SPY: yfinance received OHLC data: 1993-01-29 14:30:00 -> 2024-10-25 13:30:00
DEBUG SPY: OHLC after cleaning: 1993-01-29 09:30:00-05:00 -> 2024-10-25 09:30:00-04:00
DEBUG SPY: OHLC after combining events: 1993-01-29 00:00:00-05:00 -> 2024-10-25 00:00:00-04:00
DEBUG SPY: yfinance returning OHLC: 1993-01-29 00:00:00-05:00 -> 2024-10-25 00:00:00-04:00
DEBUG Exiting history()
DEBUG Exiting history()
DEBUG Exiting download()
Bad data proof
No response
yfinance
version0.2.48
Python version
No response
Operating system
Windows
The text was updated successfully, but these errors were encountered: