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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 14 02:33:11 CEST 2013


Author: rossbennett34
Date: 2013-08-14 02:33:11 +0200 (Wed, 14 Aug 2013)
New Revision: 2778

Modified:
   pkg/PortfolioAnalytics/R/optFUN.R
Log:
adding exposure constraint to gmv_opt and maxret_opt

Modified: pkg/PortfolioAnalytics/R/optFUN.R
===================================================================
--- pkg/PortfolioAnalytics/R/optFUN.R	2013-08-13 23:58:01 UTC (rev 2777)
+++ pkg/PortfolioAnalytics/R/optFUN.R	2013-08-14 00:33:11 UTC (rev 2778)
@@ -38,6 +38,13 @@
     rhs.vec <- c(rhs.vec, constraints$cLO, -constraints$cUP)
   }
   
+  # Add the factor exposures to Amat, dir.vec, and rhs.vec
+  if(!is.null(constraints$B)){
+    Amat <- rbind(Amat, t(B), -t(B))
+    dir.vec <- c(dir.vec, rep(">=", 2 * ncol(B)))
+    rhs.vec <- c(rhs.vec, constraints$lower, -constraints$upper)
+  }
+  
   # set up the quadratic objective
   ROI_objective <- Q_objective(Q=2*lambda*moments$var, L=-moments$mean)
   
@@ -95,6 +102,13 @@
     rhs.vec <- c(rhs.vec, constraints$cLO, -constraints$cUP)
   }
   
+  # Add the factor exposures to Amat, dir.vec, and rhs.vec
+  if(!is.null(constraints$B)){
+    Amat <- rbind(Amat, t(B), -t(B))
+    dir.vec <- c(dir.vec, rep(">=", 2 * ncol(B)))
+    rhs.vec <- c(rhs.vec, constraints$lower, -constraints$upper)
+  }
+  
   # set up the linear objective
   ROI_objective <- L_objective(L=-moments$mean)
   # objL <- -moments$mean



More information about the Returnanalytics-commits mailing list