[R-SIG-Finance] Speed issue issue with periodReturn

Ian Coe ICoe at connectcap.com
Thu Jul 30 00:06:10 CEST 2009


Hi,
  I noticed that the periodReturn function seems to a take non-trivial
amount of time to compute weekly returns. 

  The calls below all compute the log returns from 1/1/2007 to now and
they take slightly different amounts of time.

  I'd like to be able to compute weekly returns as fast as possible.
Does anyone have suggestions for minimizing the processing time?
Different data type?  Different function to call?  

Thanks,
Ian  


> yhoo=getSymbols("GOOG",source="yahoo",from = "01-01-2004")
> system.time(weeks<-periodReturn(GOOG,period="weekly",type='log',
subset="2007::"))
   user  system elapsed 
   0.06    0.00    0.06 
> yhoo=getSymbols("GOOG",source="yahoo",from = "01-01-2007")
> system.time(weeks<-periodReturn(GOOG,period="weekly",type='log',
subset="2007::"))
   user  system elapsed 
   0.04    0.00    0.07
> yhoo=getSymbols("GOOG",source="yahoo")
> system.time(weeks<-periodReturn(GOOG,period="weekly",type='log'))
   user  system elapsed 
   0.05    0.00    0.05



More information about the R-SIG-Finance mailing list