[R-SIG-Finance] Gaps in time for yahoo historical quotes?

Josh Ulrich josh.m.ulrich at gmail.com
Mon Nov 17 18:16:28 CET 2008


Hi Marc,

The adjustment algorithm will be separate from getYahooData in the
next release of TTR.  Then you'll be able to adjust data and pull data
using whichever function you prefer.

This is what I would do, though I'm not sure it's the most
correct/robust way to handle this issue.

aapl <- getYahooData("AAPl", 19910101, 20080101, quiet=TRUE)
genz <- getYahooData("GENZ", 19910101, 20080101, quiet=TRUE)
aapl <- xts(aapl[,-1],aapl[,1])
genz <- xts(genz[,-1],genz[,1])

both <- merge(aapl,genz,all=FALSE)

The all=FALSE arg removes any rows that don't appear in both objects,
giving you compatible series.

HTH,
Josh
--
http://quantemplation.blogspot.com



On Mon, Nov 17, 2008 at 10:38 AM, Marc Delvaux <mdelvaux at gmail.com> wrote:
> I am trying to get historical quotes from Yahoo.  Ideally I want high
> quality split and dividend adjusted close prices for a set of stocks.
> My history so far:
> - I started with yahooSeries in pacjage fImport.  This would be ideal,
> but it does look like the series is for non adjusted data.  I didn't
> find any function to adjust the serires yet, is there any.
> - I then used getYahooData in package TTR.  This has the split
> adjusted values I want, but it seems that the returned data series
> don't always have the same dates present.  The series are OK for the
> near past, up to about 1600 points, but some series become
> incompatible later on.  A quick illustration of the problem is shown
> below, but many series are affected in that way.  Anybody that already
> faced that problem and came with a solution to get compatible series?
> It is not a real problem if you are using only one series, but is a
> serious problems when comparing series.
>
>> aapl <- getYahooData("AAPl", 19910101, 20080101)
> End date out of range, 2007-12-31 is last available date.
> Start date out of range, 1991-01-02 is first available date.
>> genz <- getYahooData("genz", 19910101, 20080101)
> End date out of range, 2007-12-31 is last available date.
> Start date out of range, 1991-01-02 is first available date.  << GENZ
> and AAPL report same start and end date
>> dim(genz)
> [1] 4279   10
>> dim(aapl)
> [1] 4285   10   << but different number of samples
>
> After some manipulations, including reverting the time order
>
>> aapl[1488:1490,]
>          Date  Open   High    Low  Close   Volume Unadj.Close Div Split Adj.Div
> 523 2002-02-04 12.16 12.760 12.100 12.675 18656200       25.35  NA    NA      NA
> 522 2002-02-01 12.17 12.480 12.170 12.205 14225200       24.41  NA    NA      NA
> 521 2002-01-31 12.08 12.365 12.055 12.360 16730200       24.72  NA    NA      NA
>> genz[1488:1490,]
>          Date  Open  High   Low Close   Volume Unadj.Close Div Split Adj.Div
> 517 2002-02-04 46.45 46.50 43.30 44.04  5297000       44.04  NA    NA
>    NA  << where is 2002-02-01 ?
> 516 2002-01-31 44.70 46.49 44.22 45.61  4983100       45.61  NA    NA      NA
> 515 2002-01-30 45.89 46.00 40.69 44.46 13818300       44.46  NA    NA      NA
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>



More information about the R-SIG-Finance mailing list