[Returnanalytics-commits] r1934 - pkg/PortfolioAnalytics/sandbox

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Apr 30 02:03:10 CEST 2012


Author: braverock
Date: 2012-04-30 02:03:09 +0200 (Mon, 30 Apr 2012)
New Revision: 1934

Modified:
   pkg/PortfolioAnalytics/sandbox/script.workshop2012.R
Log:
- add job name and cleaned up result handling

Modified: pkg/PortfolioAnalytics/sandbox/script.workshop2012.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/script.workshop2012.R	2012-04-29 23:13:58 UTC (rev 1933)
+++ pkg/PortfolioAnalytics/sandbox/script.workshop2012.R	2012-04-30 00:03:09 UTC (rev 1934)
@@ -150,6 +150,8 @@
 # --------------------------------------------------------------------
 # @TODO: This is frosting, do it last
 
+runname='garch.sigma.and.mu'
+
 #########################################################################
 # Optimization starts here
 ########################################################################
@@ -337,7 +339,7 @@
 MeanSD.w = extractWeights.rebal(MeanSD.RND.t)
 MeanSD=Return.rebalancing(edhec.R, MeanSD.w)
 colnames(MeanSD) = "MeanSD"
-save(MeanSD.RND.t,MeanSD.w,MeanSD,file=paste('MeanSD',Sys.Date(),'rda',sep='.'))
+save(MeanSD.RND.t,MeanSD.w,MeanSD,file=paste('MeanSD',Sys.Date(),runname,'rda',sep='.'))
 
 print(paste('Completed meanSD optimization at',Sys.time(),'moving on to meanmETL'))
 
@@ -360,7 +362,7 @@
 MeanmETL.w = extractWeights.rebal(MeanmETL.RND.t)
 MeanmETL=Return.rebalancing(edhec.R, MeanmETL.w)
 colnames(MeanmETL) = "MeanmETL"
-save(MeanmETL.RND.t,MeanmETL.w,MeanmETL,file=paste('MeanmETL',Sys.Date(),'rda',sep='.'))
+save(MeanmETL.RND.t,MeanmETL.w,MeanmETL,file=paste('MeanmETL',Sys.Date(),runname,'rda',sep='.'))
 print(paste('Completed meanmETL optimization at',Sys.time(),'moving on to MinSD'))
 
 ### Evaluate BUOY 3: Constrained Minimum Variance Portfolio
@@ -382,7 +384,7 @@
 MinSD.w = extractWeights.rebal(MinSD.RND.t)
 MinSD=Return.rebalancing(edhec.R, MinSD.w)
 colnames(MinSD) = "MinSD"
-save(MinSD.RND.t,MinSD.w,MinSD,file=paste('MinSD',Sys.Date(),'rda',sep='.'))
+save(MinSD.RND.t,MinSD.w,MinSD,file=paste('MinSD',Sys.Date(),runname,'rda',sep='.'))
 print(paste('Completed MinSD optimization at',Sys.time(),'moving on to MinmETL'))
 
 ### Evaluate BUOY 4: Constrained Minimum mETL Portfolio
@@ -404,7 +406,7 @@
 MinmETL.w = extractWeights.rebal(MinmETL.RND.t)
 MinmETL=Return.rebalancing(edhec.R, MinmETL.w)
 colnames(MinmETL) = "MinmETL"
-save(MinmETL.RND.t,MinmETL.w,MinmETL,file=paste('MinmETL',Sys.Date(),'rda',sep='.'))
+save(MinmETL.RND.t,MinmETL.w,MinmETL,file=paste('MinmETL',Sys.Date(),runname,'rda',sep='.'))
 print(paste('Completed MinmETL optimization at',Sys.time(),'moving on to EqSD'))
 
 ### Evaluate BUOY 5: Constrained Equal Variance Contribution Portfolio
@@ -425,7 +427,7 @@
 EqSD.w = extractWeights.rebal(EqSD.RND.t)
 EqSD=Return.rebalancing(edhec.R, EqSD.w)
 colnames(EqSD) = "EqSD"
-save(EqSD.RND.t,EqSD.w,EqSD,file=paste('EqSD',Sys.Date(),'rda',sep='.'))
+save(EqSD.RND.t,EqSD.w,EqSD,file=paste('EqSD',Sys.Date(),runname,'rda',sep='.'))
 print(paste('Completed EqSD optimization at',Sys.time(),'moving on to EqmETL'))
 
 ### Evaluate BUOY 6: Constrained Equal mETL Contribution Portfolio
@@ -445,7 +447,7 @@
 EqmETL.w = extractWeights.rebal(EqmETL.RND.t)
 EqmETL=Return.rebalancing(edhec.R, EqmETL.w)
 colnames(EqmETL) = "EqmETL"
-save(EqmETL.RND.t,EqmETL.w,EqmETL,file=paste('EqmETL',Sys.Date(),'rda',sep='.'))
+save(EqmETL.RND.t,EqmETL.w,EqmETL,file=paste('EqmETL',Sys.Date(),runname,'rda',sep='.'))
 print(paste('Completed EqmETL optimization at',Sys.time(),'moving on to EqWgt'))
 
 ### Evaluate BUOY 7: Equal Weight Portfolio
@@ -464,32 +466,36 @@
 	tmp = Return.rebalancing(edhec.R,weights_i)
 }
 # BHportfs <- cbind(EqWgt,BHportfs)
-save(rp,BHportfs,EqWgt,file=paste('BHportfs',Sys.Date(),'rda',sep='.'))
+save(rp,BHportfs,EqWgt,file=paste('BHportfs',Sys.Date(),runname,'rda',sep='.'))
 
 end_time<-Sys.time()
 end_time-start_time
 
 # Assemble the ex ante result data
-results = c("MeanSD.RND.t", "MeanmETL.RND.t", "MinSD.RND.t", "MinmETL.RND.t", "EqSD.RND.t", "EqmETL.RND.t")
-results.names= c("Eq Wgt", "Mean SD", "Mean mETL", "Min SD", "Min mETL", "Eq SD", "Eq mETL")
+results = list(EqWgt=EqWgt,
+		BHportfs=BHportfs,
+		MeanSD.RND.t=MeanSD.RND.t, 
+		MeanmETL.RND.t=MeanmETL.RND.t, 
+		MinSD.RND.t=MinSD.RND.t, 
+		MinmETL.RND.t=MinmETL.RND.t, 
+		EqSD.RND.t=EqSD.RND.t, 
+		EqmETL.RND.t=EqmETL.RND.t)
 ## Extract Weights
-RND.weights = MeanSD.RND.t[["2010-12-31"]]$random_portfolio_objective_results[[1]]$weights #EqWgt
-for(result in results){
-    x=get(result)
-    RND.weights = rbind(RND.weights,x[["2010-12-31"]]$weights)
-}
-rownames(RND.weights)=c(results.names) # @TODO: add prettier labels
+#RND.weights = MeanSD.RND.t[["2010-12-31"]]$random_portfolio_objective_results[[1]]$weights #EqWgt
+#for(result in results){
+#	RND.weights = rbind(RND.weights,result[["2010-12-31"]]$weights)
+#}
+#results.names= c("Eq Wgt", "Mean SD", "Mean mETL", "Min SD", "Min mETL", "Eq SD", "Eq mETL")
+#rownames(RND.weights)=c(results.names) # @TODO: add prettier labels
+#
+### Extract Objective measures
+#RND.objectives=rbind(MeanSD.RND.t[["2010-12-31"]]$random_portfolio_objective_results[[1]]$objective_measures[1:3]) #EqWgt
+#for(result in results){
+#	RND.objectives = rbind(RND.objectives,rbind(result[["2010-12-31"]]$objective_measures[1:3]))
+#}
+#rownames(RND.objectives)=c("EqWgt",results) # @TODO: add prettier labels
+save(results,file=paste(Sys.Date(),runname,'full-results','rda',sep='.'))
 
-## Extract Objective measures
-RND.objectives=rbind(MeanSD.RND.t[["2010-12-31"]]$random_portfolio_objective_results[[1]]$objective_measures[1:3]) #EqWgt
-for(result in results){
-    x=get(result)
-    x.obj=rbind(x[["2010-12-31"]]$objective_measures[1:3])
-    RND.objectives = rbind(RND.objectives,x.obj)
-}
-rownames(RND.objectives)=c("EqWgt",results) # @TODO: add prettier labels
-
-
 #****************************************************************************
 # END main optimization section
 #****************************************************************************



More information about the Returnanalytics-commits mailing list