[R-SIG-Finance] getSymbols.yahoo 'adjusting' to NA

Joshua Ulrich josh.m.ulrich at gmail.com
Sun May 15 22:54:27 CEST 2011


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.
>



More information about the R-SIG-Finance mailing list