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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 19 01:48:14 CEST 2013


Author: rossbennett34
Date: 2013-06-19 01:48:13 +0200 (Wed, 19 Jun 2013)
New Revision: 2362

Modified:
   pkg/PortfolioAnalytics/R/constraints.R
Log:
adding weight_sum_constraint function

Modified: pkg/PortfolioAnalytics/R/constraints.R
===================================================================
--- pkg/PortfolioAnalytics/R/constraints.R	2013-06-18 23:45:38 UTC (rev 2361)
+++ pkg/PortfolioAnalytics/R/constraints.R	2013-06-18 23:48:13 UTC (rev 2362)
@@ -428,6 +428,24 @@
   return(Constraint)
 }
 
+#' constructor for weight_sum_constraint
+#' 
+#' This function is called by add.constraint when type="weight_sum" is specified. see \code{\link{add.constraint}}
+#' This function allows the user to specify the minimum and maximum that the weights sum to
+#' 
+#' @param type character type of the constraint
+#' @param min_sum minimum sum of all asset weights, default 0.99
+#' @param max_sum maximum sum of all asset weights, default 1.01
+#' @param enabled TRUE/FALSE
+#' @param \dots any other passthru parameters to specify box and/or group constraints
+#' @author Ross Bennett
+#' @export
+weight_sum_constraint <- function(type, min_sum=0.99, max_sum=1.01, enabled=FALSE, ...){
+  Constraint <- constraint_v2(type, ...)
+  Constraint$min_sum <- min_sum
+  Constraint$max_sum <- max_sum
+  return(Constraint)
+}
 
 #' check function for constraints
 #' 



More information about the Returnanalytics-commits mailing list