An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20110515/ccf9f360/attachment.pl>
getSymbols.yahoo 'adjusting' to NA
7 messages · G See, Joshua Ulrich
On Sun, May 15, 2011 at 3:39 PM, G See <gsee000 at gmail.com> wrote:
I think there is a bug somewhere in getSymbols.yahoo, but I haven't quite
tracked it down.
#First, an example of it working
getSymbols('SPY', to='2011-01-01')
SPY.adj <- adjustOHLC(SPY)
head(SPY.adj) #as expected
#Now, try again with earlier 'to' date
getSymbols('SPY', to='2010-01-01')
SPY.adj <- adjustOHLC(SPY)
head(SPY.adj) #NA for Op,Hi,Lo,Cl
# Try to do, "by hand," the same thing
# that getSymbols.yahoo does
getSymbols('SPY', to='2010-01-01')
div <- getDividends('SPY',to='2010-01-01')
spl <- getSplits('SPY',to='2010-01-01')
adj <- na.omit(adjRatios(spl, div, Cl(SPY)))
#head(adj); tail(adj)
fr <- SPY
fr[,1] <- fr[,1] * adj[, "Split"] * adj[, "Div"]
fr[,2] <- fr[,2] * adj[, "Split"] * adj[, "Div"]
fr[,3] <- fr[,3] * adj[, "Split"] * adj[, "Div"]
fr[,4] <- fr[,4] * adj[, "Split"] * adj[, "Div"]
fr[,5] <- fr[,5] * (1/adj[, "Div"])
head(fr) #Why did that work?
Because you included the 'to' argument in your call to getDividends and getSplits; and it's not included in those calls within getSymbols.yahoo. I'll take a closer look at this... Best, -- Joshua Ulrich | FOSS Trading: www.fosstrading.com
########### End code R> sessionInfo() R version 2.13.0 (2011-04-13) Platform: x86_64-pc-linux-gnu (64-bit) locale: ?[1] LC_CTYPE=en_US.UTF-8 ? ? ? LC_NUMERIC=C LC_TIME=en_US.UTF-8 ? ? ? ?LC_COLLATE=en_US.UTF-8 ?[5] LC_MONETARY=C ? ? ? ? ? ? ?LC_MESSAGES=en_US.UTF-8 ?LC_PAPER=en_US.UTF-8 ? ? ? LC_NAME=C ?[9] LC_ADDRESS=C ? ? ? ? ? ? ? LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats ? ? graphics ?grDevices utils ? ? datasets ?methods ? base other attached packages: [1] quantmod_0.3-15 TTR_0.20-3 ? ? ?xts_0.8-0 ? ? ? zoo_1.6-4 Defaults_1.1-1 loaded via a namespace (and not attached): [1] grid_2.13.0 ? ? lattice_0.19-26 ? ? ? ?[[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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20110515/dd8743d0/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20110515/a55fe6b9/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20110515/06b339f5/attachment.pl>
Hi Garrett,
On Sun, May 15, 2011 at 4:33 PM, G See <gsee000 at gmail.com> wrote:
Sorry. I see what you mean. adjustOHLC calls getDividends() without 'to'
# Try to do, "by hand," the same thing
# that getSymbols.yahoo does
getSymbols('SPY', to='2010-01-01')
div <- getDividends('SPY')
spl <- getSplits('SPY')
adj <- na.omit(adjRatios(spl, div, Cl(SPY)))
#head(adj); tail(adj)
fr <- SPY
fr[,1] <- fr[,1] * adj[, "Split"] * adj[, "Div"]
###End code
Now it hangs here
Thanks for looking into this.
I consider this a bug in TTR::adjRatios. It should discard any split/dividend data that lie outside the range of the close data. I will patch tonight. This issue manifests in adjustOHLC because all historical split/dividend data for "x" is pulled, not just historical data up to the last date in "x". Perhaps adjustOHLC should use a "to=" argument for getDividends and getSymbols as well... Thanks for the report! Best, -- Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Sun, May 15, 2011 at 4:13 PM, G See <gsee000 at gmail.com> wrote:
Because you included the 'to' argument in your call to getDividends and getSplits; and it's not included in those calls within getSymbols.yahoo. ?I'll take a closer look at this...
I think it is worth mentioning that getSymbols.yahoo does, in fact, use the 'to' argument to call getDividends and getSplits and is at least one reason you get big differences in yahoo's Adjusted price and the Close price after you adjust using either?adjustOHLC(), or?getSymbols() with adjust=TRUE.
Best, -- Joshua Ulrich ?| ?FOSS Trading: www.fosstrading.com
Garrett
13 days later
Garrett, My attempt to patch this a couple weeks ago uncovered some other issues (via R CMD check) that I wanted to resolve before responding. As of revision 111 on R-forge, adjRatios() ignores split/dividend data that do not have corresponding close prices. Sorry for the delay. Best, -- Joshua Ulrich ?| ?FOSS Trading: www.fosstrading.com
On Mon, May 16, 2011 at 10:43 AM, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote:
Hi Garrett, On Sun, May 15, 2011 at 4:33 PM, G See <gsee000 at gmail.com> wrote:
Sorry. I see what you mean. adjustOHLC calls getDividends() without 'to'
# Try to do, "by hand," the same thing
# that getSymbols.yahoo does
getSymbols('SPY', to='2010-01-01')
div <- getDividends('SPY')
spl <- getSplits('SPY')
adj <- na.omit(adjRatios(spl, div, Cl(SPY)))
#head(adj); tail(adj)
fr <- SPY
fr[,1] <- fr[,1] * adj[, "Split"] * adj[, "Div"]
###End code
Now it hangs here
Thanks for looking into this.
I consider this a bug in TTR::adjRatios. ?It should discard any split/dividend data that lie outside the range of the close data. ?I will patch tonight. This issue manifests in adjustOHLC because all historical split/dividend data for "x" is pulled, not just historical data up to the last date in "x". ?Perhaps adjustOHLC should use a "to=" argument for getDividends and getSymbols as well... Thanks for the report! Best, -- Joshua Ulrich ?| ?FOSS Trading: www.fosstrading.com
On Sun, May 15, 2011 at 4:13 PM, G See <gsee000 at gmail.com> wrote:
Because you included the 'to' argument in your call to getDividends and getSplits; and it's not included in those calls within getSymbols.yahoo. ?I'll take a closer look at this...
I think it is worth mentioning that getSymbols.yahoo does, in fact, use the 'to' argument to call getDividends and getSplits and is at least one reason you get big differences in yahoo's Adjusted price and the Close price after you adjust using either?adjustOHLC(), or?getSymbols() with adjust=TRUE.
Best, -- Joshua Ulrich ?| ?FOSS Trading: www.fosstrading.com
Garrett