Search code examples
rquantmod

quantmod adjustOHLC function - dividend adjusted prices


I need help in explaining a discrepancy in dividend adjusted prices using quantmod::adjustOHLC.

Get adjusted and unadjusted prices for AAPL:

library(quantmod)
getSymbols("AAPL")
AAPL.adjusted <- adjustOHLC(AAPL, adjust=c("dividend"), symbol.name="AAPL")

Last dividend for AAPL was on 2016-08-04 for 0.57 cents.

div <- getDividends("AAPL", from = "1900-01-01")
tail(div)
#            [,1]
# 2015-05-07 0.52
# 2015-08-06 0.52
# 2015-11-05 0.52
# 2016-02-04 0.52
# 2016-05-05 0.57
# 2016-08-04 0.57

For the period 5/5/2016 through 8/3/2016, when adjustOHLC when called to adjust only for dividends my expectation is for it to deduct 0.57 cents from OHLC prices for these dates.

But, I don't see an exact difference of 0.57 cents when computing differences between unadjusted and adjusted closing prices.

div <- coredata(AAPL["2016-05-05/2016-08-03"][,"AAPL.Close"] -
       AAPL.adjusted["2016-05-05/2016-08-03"][,"AAPL.Close"])
hist(div)

In the plotted histogram, most prices are not close to 0.57.

Looking into code of adjustOHLC, computed adjustment factors are identical for the interested date range

div <- getDividends("AAPL", from = "1900-01-01")
splits <- getSplits("AAPL", from = "1900-01-01")
div <- div * 1/adjRatios(splits=merge(splits, index(div)))[, 1]
ratios <- adjRatios(splits, div, Cl(AAPL))
length(ratios["2016-05-05/2016-08-03"][, "Div"])
# [1] 63
table(ratios["2016-05-05/2016-08-03"][, "Div"])
# 0.994611967155573
#                63

Why there is so much variation in differences of unadjusted and adjusted closing prices?


Solution

  • The calculation by quantmod::adjustOHLC is correct. The discrepancy is in your assumptions and expectations.

    There is no reason to expect the difference between unadjusted and adjusted close prices to be equal to the dividend amount, except on the ex-dividend date and any other dates with an identical close price as the ex-dividend date.

    You even note that, "computed adjustment factors are identical for the interested date range" (emphasis added). The adjustment factor will be identical until there is another dividend or split. The adjusted close is calculated by multiplying the adjustment factor and the unadjusted close price.

    If you simply subtracted the dividend amount from all prior close prices, you would change the returns and it could possibly even cause the close price to become negative!