Path: blob/master/sandbox/symposium2013/parse.EDHEC.R
1433 views
### Construct an xts object of EDHEC composite hedge fund style indexes12# Peter Carl34# Used for updating the edhec data object in PerformanceAnalytics56require(gdata)7require(xts)8910### Constants11filename = "EDHEC-index-history.csv"12objectname = "edhec"13datadir = "./data"14cachedir = "./cache"1516# Download the following file to the working directory:17# http://www.edhec-risk.com/indexes/pure_style/data/table/history.csv18### @TODO: Is there a way to download it directly? Maybe not, seems to require a login1920### Read data from csv file21x=read.csv(file=paste(datadir,filename,sep="/"), sep=";", header=TRUE, check.names=FALSE)22x.dates = as.Date(x[,1], format="%d/%m/%Y")23x.data = apply(x[,-1], MARGIN=2, FUN=function(x){as.numeric(sub("%","", x, fixed=TRUE))/100}) # get rid of percentage signs24edhec = xts(x.data, order.by=x.dates)2526### Add pretty columnnames as an xts attribute?272829### Save data into cache30save(edhec, file=paste(cachedir, "/", objectname, ".RData", sep=""))3132