[R-SIG-Finance] Monthly returns from Daily prices
Ravi S. Shankar
ravis at ambaresearch.com
Mon Mar 24 12:26:01 CET 2008
Hi,
I have the daily data in the following format
RIC Trade.Date Close.Price Currency.Code
ABCd.xx 2008/02/29 15.3 CNY
ABCd.xx 2008/02/28 15.1 CNY
ABCd.xx 2008/02/27 15.28 CNY
ABCd.xx 2008/02/26 15.26 CNY
ABCd.xx 2008/02/25 14.88 CNY
ABCd.xx 2008/02/22 15.64 CNY
I have about 1000 rics and one year daily price history for each of the
rics. I need to compute the monthly returns for this data.
I tried the following code to get the monthly data from the daily prices
library(zoo)
ss=read.csv("C:\\Documents and
Settings\\ravis\\Desktop\\ravi.csv",header=T)
ss$Trade.Date=as.Date(ss$Trade.Date,"%Y/%m/%d")
ss$ym=as.yearmon(ss$Trade.Date)
ss.mon=aggregate(ss$Close.Price,list(RIC=ss$RIC,Month_Year=ss$ym),functi
on(x) tail(x,1))
I am interested in an alternate way of doing this.
Any help would be appreciated.
Thank you,
Regards,
Ravi Shankar S
This e-mail may contain confidential and/or privileged i...{{dropped:10}}
More information about the R-SIG-Finance
mailing list