Closed Dro1000 closed 4 years ago
The split.adjust parameter is TRUE by default. I do not know whether this is correct or not. But by setting it to FALSE, you get the value you want:
quantmod::getDividends("AAPL", split.adjust=FALSE)['2014-05-08']
I think getDividends()
is correct here, because it adjusts for splits by default.
According to AAPL's website, there was a 7-for-1 stock split on 2014-06-09 and a $0.47 dividend on 2014-08-14. getDividends()
returns the split-adjusted dividends by default, so $0.067142 = 0.47/7.
There are unit tests that should fail if Yahoo changes how they return data.
The table below shows a comparison between Apple data and Yahoo data thru quantmod::getDividends("AAPL", split.adjust=FALSE).
date | apple | yahoo | calc yahoo |
---|---|---|---|
1995-xx-xx | .12 | 0.00429 | .12/2/2/7 |
2000-06-21 | 2-for-1 | _ | _ |
2005-02-28 | 2-for-1 | _ | _ |
2012-08-09 | 2.65 | 0.37857 | 2.65/7 |
2014-05-08 | 3.29 | 0.47000 | 3.29/7 |
2014-06-08 | 7-for-1 | _ | _ |
2014-08-07 | 0.47 | 0.47 | since then apple=yahoo |
After a split, prior data gets adjusted. Looks like Yahoo AAPL dividends are coming already adjusted. And, as @Dro1000 pointed out, quantmod::getDividends("AAPL", split.adjust=TRUE) is indeed adjusting them a second time. However, after checking the unit tests for CF and a couple more big companies like IBM,NKE,V with recent splits, it seems that quantmod::getDividends is working correctly. Which brings the conclusion that the bug is in Yahoo data for AAPL (and maybe others...)
Description
Hi! It seems that getDividends adjusted dividends for splits twice.
Expected behavior
For example, function quantmod::getDividends("AAPL") return xts object, where on 2014-05-08 its value is 0.067142 = 3.29 / 49, but valid value must be 0.47 = 3.29 / 7. I think, the function adjusts already adjusted data.