[Returnanalytics-commits] r2780 - pkg/PortfolioAnalytics/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 14 03:17:52 CEST 2013


Author: rossbennett34
Date: 2013-08-14 03:17:50 +0200 (Wed, 14 Aug 2013)
New Revision: 2780

Modified:
   pkg/PortfolioAnalytics/R/optFUN.R
Log:
adding exposure constraints to etl_opt

Modified: pkg/PortfolioAnalytics/R/optFUN.R
===================================================================
--- pkg/PortfolioAnalytics/R/optFUN.R	2013-08-14 00:52:52 UTC (rev 2779)
+++ pkg/PortfolioAnalytics/R/optFUN.R	2013-08-14 01:17:50 UTC (rev 2780)
@@ -264,6 +264,14 @@
     dir.vec <- c(dir.vec, rep(">=", (n.groups + n.groups)))
     rhs.vec <- c(rhs.vec, constraints$cLO, -constraints$cUP)
   }
+  # Add the factor exposures to Amat, dir, and rhs
+  if(!is.null(constraints$B)){
+    t.B <- t(B)
+    zeros <- matrix(data=0, nrow=nrow(t.B), ncol=(T+1))
+    Amat <- rbind(Amat, cbind(t.B, zeros), cbind(-t.B, zeros))
+    dir.vec <- c(dir.vec, rep(">=", 2 * nrow(t.B)))
+    rhs.vec <- c(rhs.vec, constraints$lower, -constraints$upper)
+  }
   
   ROI_objective <- L_objective(c(rep(0,N), rep(1/(alpha*T),T), 1))
   opt.prob <- OP(objective=ROI_objective, 



More information about the Returnanalytics-commits mailing list