Skip to content
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

Yahoo data changed from EST to UTC? #2327

Open
man-chan opened this issue Feb 24, 2025 · 2 comments
Open

Yahoo data changed from EST to UTC? #2327

man-chan opened this issue Feb 24, 2025 · 2 comments

Comments

@man-chan
Copy link

I'm not sure is my bug or Yahoo or yFinance. Since I didn't log the command I used, so I guess the command should look similar to the following. Not sure the change in Yahoo data or yFinance.

This week, I got saved 2025-02-14 data as follow. I am using yFinance 0.2.54 & python 3.9.

yf.download('SPY', '2025-02-08', '2025-02-22', interval='1h', progress=False)

2025-02-14,09:00:00,609.31,610.5,609.22,610.26,0
2025-02-14,10:00:00,610.33,610.51,609.41,609.74,0
2025-02-14,11:00:00,609.73,609.74,608.67,608.73,0
2025-02-14,12:00:00,608.73,609.3,608.6,609.1,0
2025-02-14,13:00:00,609.11,611.0,608.76,609.39,0
2025-02-14,14:00:00,609.45,610.0,609.02,609.845,0
2025-02-14,14:30:00,609.9400024414062,610.989990234375,609.760009765625,610.239990234375,5214577
2025-02-14,15:30:00,610.239990234375,610.8499755859375,609.4000244140625,609.989990234375,3910433
2025-02-14,16:30:00,610.010009765625,610.2949829101562,609.27001953125,609.3201293945312,2764489
2025-02-14,17:30:00,609.3499755859375,610.0900268554688,609.0700073242188,609.9298706054688,1443250
2025-02-14,18:30:00,609.9299926757812,610.7506713867188,609.8800048828125,610.1300048828125,2059667
2025-02-14,19:30:00,610.1500244140625,610.3024291992188,609.5900268554688,609.6699829101562,2430485
2025-02-14,20:30:00,609.6599731445312,610.2899780273438,609.5449829101562,609.7000122070312,5528441
2025-02-14,21:00:00,609.69,610.0901,609.42,609.928,0
2025-02-14,22:00:00,609.93,609.95,609.66,609.83,0
2025-02-14,23:00:00,609.78,609.88,609.47,609.625,0
2025-02-18,09:00:00,610.77,611.91,610.77,611.51,0

Last week, I got the saved data, I was using 0.1.69 (worked like this for years).

yf.download('SPY', '2025-02-01', '2025-02-15', interval='1h', progress=False) 

2025-02-14,04:00:00,609.31,610.5,609.22,610.26,610.26,0
2025-02-14,05:00:00,610.33,610.51,609.41,609.74,609.74,0
2025-02-14,06:00:00,609.73,609.74,608.67,608.73,608.73,0
2025-02-14,07:00:00,608.73,609.3,608.6,609.1,609.1,0
2025-02-14,08:00:00,609.11,611.0,608.76,609.39,609.39,0
2025-02-14,09:00:00,609.45,610.0,609.02,609.845,609.845,0
2025-02-14,09:30:00,609.9400024414062,610.989990234375,609.760009765625,610.239990234375,610.239990234375,5214577
2025-02-14,10:30:00,610.239990234375,610.8499755859375,609.4000244140625,609.989990234375,609.989990234375,3910433
2025-02-14,11:30:00,610.010009765625,610.2949829101562,609.27001953125,609.3201293945312,609.3201293945312,2764489
2025-02-14,12:30:00,609.3499755859375,610.0900268554688,609.0700073242188,609.9298706054688,609.9298706054688,1443250
2025-02-14,13:30:00,609.9299926757812,610.7506713867188,609.8800048828125,610.1300048828125,610.1300048828125,2059667
2025-02-14,14:30:00,610.1500244140625,610.3024291992188,609.5900268554688,609.6699829101562,609.6699829101562,2430485
2025-02-14,15:30:00,609.6599731445312,610.2899780273438,609.5449829101562,609.7000122070312,609.7000122070312,5528441
2025-02-14,16:00:00,609.69,610.0901,609.42,609.928,609.928,0
2025-02-14,17:00:00,609.93,609.95,609.66,609.83,609.83,0
2025-02-14,18:00:00,609.78,609.88,609.47,609.625,609.625,0
2025-02-14,19:59:57,609.8,609.8,609.8,609.8,609.8,0

This is how I save the data

df.to_csv(filename, encoding='utf-8', columns=columns, index=False, compression='gzip')

I am still investigating the discrepancy, and I guess because the end date is exclusive, so I will need to advance one day to pull the data today or I will hit the ticker delisted issue.

@ValueRaider
Copy link
Collaborator

That's a bug. Most recent change 4157b9e

Workaround = yf.Ticker("SPY").history(...)

@man-chan
Copy link
Author

Thank you. I manage to pull the data as you suggest.

df = yf.Ticker('SPY').history(interval='1d', start='2025-02-03', end='2025-02-07')

For the clarity, I would like to specify the date with the timezone. Not sure whether this is consistent with the design?

ticker = yf.Ticker('SPY')
ticker._tz = 'UTC'
df = ticker.history(interval='1d', start='2025-02-03', end='2025-02-07')

If possible, I prefer the code take the timezone from start and end datetime objects. Currently yf ignore this information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants