yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

bug: yf.download() of 1d EURUSD=X data has the same open and closing price

Open snafu4 opened this issue 3 years ago • 6 comments

` yf.download('GBPUSD=X', interval='1d', period="10d")

[100%**] 1 of 1 completed Open High Low Close Adj Close Volume Date
2022-09-20 1.002959 1.005025 0.995708 1.002959 1.002959 0 2022-09-21 0.997079 0.997407 0.986914 0.997079 0.997079 0 2022-09-22 0.983072 0.990619 0.981104 0.983072 0.983072 0 2022-09-23 0.984155 0.985222 0.970393 0.984155 0.984155 0 2022-09-26 0.968992 0.969989 0.958231 0.968992 0.968992 0 2022-09-27 0.962371 0.967006 0.959453 0.962371 0.962371 0 2022-09-28 0.959619 0.968626 0.954016 0.959619 0.959619 0 2022-09-29 0.970817 0.978732 0.963828 0.970817 0.970817 0 2022-09-30 0.982956 0.984999 0.973606 0.982956 0.982956 0 2022-10-03 0.977230 0.984640 0.975515 0.982994 0.982994 0

` yfinance 0.1.74 pandas 1.5.0 Python 3.9.12

snafu4 avatar Oct 03 '22 20:10 snafu4

I agree that's wrong but this is what Yahoo has on their website so nothing we can do. Other than wait for Yahoo to fix, because I'm sure it was fine recently so maybe Yahoo messing around.

ValueRaider avatar Oct 03 '22 22:10 ValueRaider

There are actually hundreds of candles with this issue, doesn't seem to be a temporary problem https://github.com/ranaroussi/yfinance/issues/1075#issue-1396356550

Karlheinzniebuhr avatar Oct 04 '22 16:10 Karlheinzniebuhr

What I mean is, assuming that Yahoo was displaying correct candles until recently (which I think is true), that Yahoo has recently introduced a change or bug in their backend that either (i) mixed up the fetching of daily open/close from their database, or (ii) overwrote their database.

Just because an old candle (e.g. 2020) is being displayed today incorrect doesn't mean it was displayed incorrect in 2020.

ValueRaider avatar Oct 04 '22 16:10 ValueRaider

Response from Yahoo received Thu, Oct 6 (eastern).

NOTE: This is a problem for more than just EURUSD=X, other currency pairs have incorrect 'close'/'adj close' DAILY values. They may not be exactly the same as the open but they are only a few PIPs off (which are also incorrect).

Screenshot 2022-10-10 092727

snafu4 avatar Oct 10 '22 13:10 snafu4

I realize this is not a yfinance problem (indirectly it is) but it was never resolved. I would leave it open so that everyone sees the issue.

snafu4 avatar Jan 06 '23 23:01 snafu4

Probably Yahoo never resolved because the fix is simple: close = open tomorrow. Because market is 24 hours.

import numpy as np
close = np.roll(df["Open"].to_numpy(), -1)
close[-1] = df["Close"][-1]
df["Close"] = close

I'll let someone else polish & submit a PR. Might be a PR not possible because must restrict to 24-hour markets.

ValueRaider avatar Jan 06 '23 23:01 ValueRaider