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
adjustOHLC bug with Yahoo! Data after URL change #160
Comments
yes, there's something broken: check SPXL for example 2017-05-01: > spxl[index(spxl) >= "2017-04-28" & index(spxl) <= "2017-05-01"]
SPXL.Open SPXL.High SPXL.Low SPXL.Close SPXL.Volume SPXL.Adjusted
2017-04-28 524.48 524.48 517.84 519.04 510300 129.76
2017-05-01 32.63 32.86 32.46 32.63 1042100 32.63
> adjustOHLC(spxl, use.Adjusted = TRUE)[index(spxl) >= "2017-04-28" & index(spxl) <= "2017-05-01"]
SPXL.Open SPXL.High SPXL.Low SPXL.Close SPXL.Volume SPXL.Adjusted
2017-04-28 131.12 131.12 129.46 129.76 510300 129.76
2017-05-01 32.63 32.86 32.46 32.63 1042100 32.63
> adjustOHLC(spxl, use.Adjusted = FALSE)[index(spxl) >= "2017-04-28" & index(spxl) <= "2017-05-01"]
SPXL.Open SPXL.High SPXL.Low SPXL.Close SPXL.Volume SPXL.Adjusted
2017-04-28 131.12 131.12 129.46 129.76 510300 129.76
2017-05-01 32.63 32.86 32.46 32.63 1042100 32.63 |
@javcasalc You should consider using xts' ISO-8601 subsetting. It's much easier to type and read. ;) spxl["2017-04-28/2017-05-01"] |
@joshuaulrich any clue on how to deal with this yahoo issue? Thanks! |
I don't think I can fix these. They look like errors in the raw data. In the case of XLF, Yahoo says it has a split and a dividend on 2016-09-16, even on their webpage. As far as I can tell, there was only a special dividend. The split and dividend data are roughly the same ratio, and The problem with SPXL is that the adjusted close price isn't adjusted for the 4/1 split on 2017-05-01, which is also reflected on it's webpage. There's not much I can do when the raw data are randomly incorrect... |
@joshuaulrich I agree the problem occurs in raw data, but I am not sure if it happened in only random symbols. I found that the "adjusted closed" in Yahoo Finance handle split correctly, but dividend is incorrect. Just look at AAPL on May 11, 2017, and MSFT on May 16, 2017. Dividends are not reflected on the adjusted closed. |
Even though adjustOHLC doesn't throw any errors, I'm not sure it's properly adjusting the data. Try downloading data for SPY, adjustOHLC, create a daily return series and compare annual returns to S&P 500 Total Returns Index. There's a big difference now. It appears dividends are no longer adjusted, or maybe the raw data is bad altogether. Yahoo has really messed up everything! |
Is there any other dividend adjustment dataset can be used? Honestly, Yahoo Finance doesn't seem reliable for now. |
Closing, since this is a data source issue that can't be fixed with code changes. |
This seems to happen since the patch for the change in Yahoo URL. It may be a specific issue with this security, XLF, or it may be a systemic issue with processing Yahoo's dividend and split data since the URL change.
XLF had a special dividend on September 19 2016, in which it split into two ETFs, XLRE and a new XLF. Its an open question whether its economically right to link the old XLF to the new XLF time series, but, even so, this looks like an error:
You see the raw data above has a break between 09-16 and 09-19, whereas the Yahoo! calculated Adjusted Close is a smooth time series. Now look at the adjustOLHC:
head(adjustOHLC(XLF))
look again at the break between 09-16 and 09-19. However, this looks ok:
I can't tell what data the function is reading from Yahoo!, but my guess is that somehow the dividend is applied twice.
Session Info
The text was updated successfully, but these errors were encountered: