[Returnanalytics-commits] r2574 - in pkg/PortfolioAnalytics: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jul 15 04:12:44 CEST 2013


Author: rossbennett34
Date: 2013-07-15 04:12:43 +0200 (Mon, 15 Jul 2013)
New Revision: 2574

Modified:
   pkg/PortfolioAnalytics/DESCRIPTION
   pkg/PortfolioAnalytics/R/optimize.portfolio.R
Log:
modified optimize_method=ROI call to subfunctions

Modified: pkg/PortfolioAnalytics/DESCRIPTION
===================================================================
--- pkg/PortfolioAnalytics/DESCRIPTION	2013-07-14 22:07:21 UTC (rev 2573)
+++ pkg/PortfolioAnalytics/DESCRIPTION	2013-07-15 02:12:43 UTC (rev 2574)
@@ -45,3 +45,4 @@
     'portfolio.R'
     'constraintsFUN.R'
     'constraint_fn_map.R'
+    'optFUN.R'

Modified: pkg/PortfolioAnalytics/R/optimize.portfolio.R
===================================================================
--- pkg/PortfolioAnalytics/R/optimize.portfolio.R	2013-07-14 22:07:21 UTC (rev 2573)
+++ pkg/PortfolioAnalytics/R/optimize.portfolio.R	2013-07-15 02:12:43 UTC (rev 2574)
@@ -757,19 +757,34 @@
       }
     }
     if("var" %in% names(moments)){
-      # Then this is a QP problem
+      # Minimize variance if the only objective specified is variance
+      # Maximize Quadratic Utility if var and mean are specified as objectives
       out <- gmv_opt(R=R, constraints=constraints, moments=moments, lambda=lambda, target=target)
       out$call <- call
     }
-    if(names(moments) == "mean") {
-      # This is a maximize return problem if the only name in moments == mean
-      out <- maxret_opt(R=R, constraints=constraints, moments=moments, target=target)
-      out$call <- call
+    if(length(names(moments)) == 1 & "mean" %in% names(moments)) {
+      # Maximize return if the only objective specified is mean
+      if(!is.null(constraints$max_pos)) {
+        # This is an MILP problem if max_pos is specified as a constraint
+        out <- maxret_milp_opt(R=R, constraints=constraints, moments=moments, target=target)
+        out$call <- call
+      } else {
+        # Maximize return LP problem
+        out <- maxret_opt(R=R, constraints=constraints, moments=moments, target=target)
+        out$call <- call
+      }
     }
     if( any(c("CVaR", "ES", "ETL") %in% names(moments)) ) {
-      # This is an ETL LP problem
-      out <- etl_opt(R=R, constraints=constraints, moments=moments, target=target, alpha=alpha)
-      out$call <- call
+      # Minimize sample ETL/ES/CVaR if CVaR, ETL, or ES is specified as an objective
+      if(!is.null(constraints$max_pos)) {
+        # This is an MILP problem if max_pos is specified as a constraint
+        out <- etl_milp_opt(R=R, constraints=constraints, moments=moments, target=target, alpha=alpha)
+        out$call <- call
+      } else {
+        # Minimize sample ETL/ES/CVaR LP Problem
+        out <- etl_opt(R=R, constraints=constraints, moments=moments, target=target, alpha=alpha)
+        out$call <- call
+      }
     }
   } ## end case for ROI
   



More information about the Returnanalytics-commits mailing list