[Returnanalytics-commits] r3181 - pkg/PortfolioAnalytics/sandbox/symposium2013
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Sep 24 04:07:58 CEST 2013
Author: peter_carl
Date: 2013-09-24 04:07:57 +0200 (Tue, 24 Sep 2013)
New Revision: 3181
Modified:
pkg/PortfolioAnalytics/sandbox/symposium2013/optimize.HFindexes.R
Log:
- extracting portfolio measures won't work across all buoys, so re-calculating them based on weights and returns
Modified: pkg/PortfolioAnalytics/sandbox/symposium2013/optimize.HFindexes.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/symposium2013/optimize.HFindexes.R 2013-09-24 01:56:43 UTC (rev 3180)
+++ pkg/PortfolioAnalytics/sandbox/symposium2013/optimize.HFindexes.R 2013-09-24 02:07:57 UTC (rev 3181)
@@ -204,11 +204,11 @@
name="mean"
)
# Add a risk measure
-
# Use ES to be consistent with risk measures in other BUOY portfolios
RiskBudget.portf <- add.objective(portfolio=RiskBudget.portf,
type="risk",
name="ES",
+ multiplier=1,
arguments = list(p=(1-1/12), clean=clean)
)
@@ -257,8 +257,18 @@
plot(MeanmETL.ROI, risk.col="StdDev", return.col="mean", rp=permutations, chart.assets=TRUE, main="Mean-mETL Portfolio")
plot(MeanmETL.ROI, risk.col="ES", return.col="mean", rp=permutations, chart.assets=TRUE, main="Mean-mETL Portfolio")
save(MeanmETL.ROI,file=paste(resultsdir, 'MeanETL-', Sys.Date(), '-', runname, '.rda',sep=''))
+chart.EfficientFrontier(MeanmETL.RND)
print(paste('Completed meanmETL optimization at',Sys.time(),'moving on to MinSD'))
+MeanmETL.RND<-optimize.portfolio(R=R,
+ portfolio=MeanmETL.portf,
+ optimize_method='random',
+ search_size=10000,
+ trace=TRUE
+)
+plot(MeanmETL.RND, risk.col="StdDev", return.col="mean", chart.assets=TRUE, main="Mean-mETL Portfolio")
+plot(MeanmETL.RND, risk.col="ES", return.col="mean", chart.assets=TRUE, main="Mean-mETL Portfolio")
+
### Evaluate BUOY 3: Constrained Minimum Variance Portfolio - with ROI
MinSD.ROI<-optimize.portfolio(R=R,
portfolio=MinSD.portf,
@@ -364,7 +374,21 @@
buoyStdDev <- combine.optimizations(list(EqSD=EqSD.RND, EqWt=EqWt.opt))
chart.RiskBudget(buoyStdDev, match.col="StdDev", risk.type="absolute", legend.loc="topleft")
+Wgts = extractWeights(buoys)
+# Extract portfolio measures from each objective
+## We can't just extract them, because they aren't all calculated
+## so fill them in...
+portfmeas=NULL
+for(i in 1:NROW(Wgts)){
+ mean = sum(colMeans(R)*Wgts[i,])
+ sd = StdDev(R, weights=Wgts[i,])
+ es = ES(R, weights=Wgts[i,], method="modified", portfolio_method="component", p=p)
+ portfmeas=rbind(portfmeas, c(mean, sd[1], es[1]))
+}
+colnames(portfmeas)=c("Mean", "StdDev", "mETL")
+rownames(portfmeas)=rownames(Wgts)
+
end_time<-Sys.time()
end_time-start_time
More information about the Returnanalytics-commits
mailing list