does quantmod::adjustOHLC adust for dividends?
Thank you. I see that the IBM.Open, IBM.High, IBM.Low, and IBM.Close columnsare adjusted for dividends, and IBM.Adjusted column actually contains the raw close.This is fine as long the user knows this -- the naming of the columns could suggestthe reverse.
Before Yahoo changed its data format, when I used?getYahooData from package TTR to get data, the fields returned wereOpen,High,Low,Close,Volume,Unadj.Close,Div,Split,Adj.Div . I think the label "Unadj.Close" for the raw close
is more descriptive.
Vivek Rao
From: Joshua Ulrich <josh.m.ulrich at gmail.com>
To: Ilya Kipnis <ilya.kipnis at gmail.com>
Cc: Vivek Rao <vivekrao4 at yahoo.com>; "r-sig-finance at r-project.org" <r-sig-finance at r-project.org>
Sent: Friday, June 2, 2017 10:51 AM
Subject: Re: [R-SIG-Finance] does quantmod::adjustOHLC adust for dividends?
On Fri, Jun 2, 2017 at 9:47 AM, Ilya Kipnis <ilya.kipnis at gmail.com> wrote:
That's a function of yahoo data no longer adjusting for dividends.
No, it isn't.
On Fri, Jun 2, 2017 at 10:45 AM, Vivek Rao via R-SIG-Finance < r-sig-finance at r-project.org> wrote:
(I tried sending this message before joining the group, but it was held
for moderation.)
It appears that the adjustOHLC function of the quantmod package does not
create an .Adjusted field
that reflects dividends.
The code
library("quantmod")
sym <- "IBM"
START.DATE = "2016-01-01"
div <- getDividends(sym,auto.assign=FALSE,from=START.DATE)
xx <- getSymbols(sym, from=START.DATE, src="yahoo", auto.assign=FALSE)
xx.a <- adjustOHLC(xx)
xx.uA <- adjustOHLC(xx, use.Adjusted=TRUE)
The issue is that you must set the symbol.name argument if the first argument to adjustOHLC() is not named the same as the symbol being adjusted. This works: xx.a2 <- adjustOHLC(xx, symbol.name = sym) head(xx.a2) ? ? ? ? ? IBM.Open IBM.High? IBM.Low IBM.Close IBM.Volume IBM.Adjusted 2016-01-04 128.3440 128.6942 127.0568? 128.6753? ? 5229400? ? ? 135.95 2016-01-05 129.4420 129.5650 127.6342? 128.5807? ? 3924800? ? ? 135.85 2016-01-06 127.1893 128.3251 126.4700? 127.9371? ? 4310900? ? ? 135.17 2016-01-07 126.5457 127.7951 125.3437? 125.7507? ? 7025800? ? ? 132.86 2016-01-08 126.0535 126.6593 124.2931? 124.5865? ? 4762700? ? ? 131.63 2016-01-11 124.7568 126.6593 124.7095? 126.1009? ? 4974400? ? ? 133.23
cat("\ndiv\n")
print(head(div))
cat("\nxx\n")
print(head(xx))
cat("\nxx.a\n")
print(head(xx.a))
cat("\nxx.uA\n")
print(head(xx.uA))
produces the output below. I'd expect that IBM.Adjusted field to have
different values
at the beginning of the period, depending on whether one adjusts for
dividends.
div
IBM.div
2016-02-08? ? 1.3
2016-05-06? ? 1.4
2016-08-08? ? 1.4
2016-11-08? ? 1.4
2017-02-08? ? 1.4
2017-05-08? ? 1.5
xx
IBM.Open IBM.High IBM.Low IBM.Close IBM.Volume IBM.Adjusted
2016-01-04? 135.60? 135.97? 134.24? ? 135.95? ? 5229400? ? ? 135.95
2016-01-05? 136.76? 136.89? 134.85? ? 135.85? ? 3924800? ? ? 135.85
2016-01-06? 134.38? 135.58? 133.62? ? 135.17? ? 4310900? ? ? 135.17
2016-01-07? 133.70? 135.02? 132.43? ? 132.86? ? 7025800? ? ? 132.86
2016-01-08? 133.18? 133.82? 131.32? ? 131.63? ? 4762700? ? ? 131.63
2016-01-11? 131.81? 133.82? 131.76? ? 133.23? ? 4974400? ? ? 133.23
xx.a
IBM.Open IBM.High IBM.Low IBM.Close IBM.Volume IBM.Adjusted
2016-01-04? 135.60? 135.97? 134.24? ? 135.95? ? 5229400? ? ? 135.95
2016-01-05? 136.76? 136.89? 134.85? ? 135.85? ? 3924800? ? ? 135.85
2016-01-06? 134.38? 135.58? 133.62? ? 135.17? ? 4310900? ? ? 135.17
2016-01-07? 133.70? 135.02? 132.43? ? 132.86? ? 7025800? ? ? 132.86
2016-01-08? 133.18? 133.82? 131.32? ? 131.63? ? 4762700? ? ? 131.63
2016-01-11? 131.81? 133.82? 131.76? ? 133.23? ? 4974400? ? ? 133.23
xx.uA
IBM.Open IBM.High IBM.Low IBM.Close IBM.Volume IBM.Adjusted
2016-01-04? 135.60? 135.97? 134.24? ? 135.95? ? 5229400? ? ? 135.95
2016-01-05? 136.76? 136.89? 134.85? ? 135.85? ? 3924800? ? ? 135.85
2016-01-06? 134.38? 135.58? 133.62? ? 135.17? ? 4310900? ? ? 135.17
2016-01-07? 133.70? 135.02? 132.43? ? 132.86? ? 7025800? ? ? 132.86
2016-01-08? 133.18? 133.82? 131.32? ? 131.63? ? 4762700? ? ? 131.63
2016-01-11? 131.81? 133.82? 131.76? ? 133.23? ? 4974400? ? ? 133.23
Vivek Rao
_______________________________________________ R-SIG-Finance at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
? ? ? ? [[alternative HTML version deleted]]
_______________________________________________ R-SIG-Finance at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Joshua Ulrich? |? about.me/joshuaulrich FOSS Trading? |? www.fosstrading.com R/Finance 2017 | www.rinfinance.com [[alternative HTML version deleted]]