[Returnanalytics-commits] r3091 - pkg/PortfolioAnalytics/sandbox/symposium2013

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Sep 13 18:21:40 CEST 2013


Author: peter_carl
Date: 2013-09-13 18:21:40 +0200 (Fri, 13 Sep 2013)
New Revision: 3091

Modified:
   pkg/PortfolioAnalytics/sandbox/symposium2013/parse.EDHEC.R
Log:
- modified to fit the workspace
- should be very easy to update now, written more generally


Modified: pkg/PortfolioAnalytics/sandbox/symposium2013/parse.EDHEC.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/symposium2013/parse.EDHEC.R	2013-09-13 16:18:30 UTC (rev 3090)
+++ pkg/PortfolioAnalytics/sandbox/symposium2013/parse.EDHEC.R	2013-09-13 16:21:40 UTC (rev 3091)
@@ -7,26 +7,25 @@
 require(gdata)
 require(xts)
 
+
+### Constants
+filename = "EDHEC-index-history.csv"
+objectname = "edhec"
+datadir = "./data"
+cachedir = "./cache"
+
 # Download the following file to the working directory:
 # http://www.edhec-risk.com/indexes/pure_style/data/table/history.csv
 ### @TODO: Is there a way to download it directly? Maybe not, seems to require a login
-x=read.csv(file="history.csv", sep=";", header=TRUE, check.names=FALSE)
+
+### Read data from csv file
+x=read.csv(file=paste(datadir,filename,sep="/"), sep=";", header=TRUE, check.names=FALSE)
 x.dates = as.Date(x[,1], format="%d/%m/%Y")
 x.data = apply(x[,-1], MARGIN=2, FUN=function(x){as.numeric(sub("%","", x, fixed=TRUE))/100}) # get rid of percentage signs
 edhec = xts(x.data, order.by=x.dates)
-colnames(edhec)
 
-# calculate a wealth index
-edhec.idx = apply(edhec, MARGIN=2, FUN=function(x){cumprod(1 + na.omit(x))})
-# identify quarters
-edhec.Q.idx=edhec.idx[endpoints(edhec.idx, on="quarters"),]
-# calculate quarterly returns
-edhec.Q.R=ROC(edhec.Q.idx)
-# trim the last data point, if needed
-# dim(edhec.Q.R)
-# edhec.Q.R=edhec.Q.R[-61,]
-# reclass the object
-edhec.Q.R=as.xts(edhec.Q.R)
-# lm requires safe names
-colnames(edhec.Q.R)=make.names(colnames(edhec))
+### Add pretty columnnames as an xts attribute?
 
+
+### Save data into cache
+save(edhec, file=paste(cachedir, "/", objectname, ".RData", sep=""))
\ No newline at end of file



More information about the Returnanalytics-commits mailing list