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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jun 21 04:34:48 CEST 2013


Author: rossbennett34
Date: 2013-06-21 04:34:47 +0200 (Fri, 21 Jun 2013)
New Revision: 2391

Modified:
   pkg/PortfolioAnalytics/R/constraints.R
Log:
adding turnover_constraint function and updating add.constraint for turnover constraint

Modified: pkg/PortfolioAnalytics/R/constraints.R
===================================================================
--- pkg/PortfolioAnalytics/R/constraints.R	2013-06-20 16:39:28 UTC (rev 2390)
+++ pkg/PortfolioAnalytics/R/constraints.R	2013-06-21 02:34:47 UTC (rev 2391)
@@ -274,6 +274,10 @@
          weight=, weight_sum = {tmp_constraint <- weight_sum_constraint(type=type,
                                                                         ...=...)
          },
+         # Turnover constraint
+         turnover = {tmp_constraint <- turnover_constraint(type=type,
+                                                           ...=...)
+         },
          # Do nothing and return the portfolio object if type is NULL
          null = {return(portfolio)}
   )
@@ -495,6 +499,25 @@
   return(structure(out, class="constraint"))
 }
 
+#' constructor for turnover_constraint
+#' 
+#' This function is called by add.constraint when type="turnover" is specified. see \code{\link{add.constraint}}
+#' This function allows the user to specify a maximum turnover constraint
+#' 
+#' Note that turnover constraint is currently only supported for global minimum variance problem with solve.QP plugin
+#' 
+#' @param type character type of the constraint
+#' @param max.turnover maximum turnover value
+#' @param enabled TRUE/FALSE
+#' @param \dots any other passthru parameters to specify box and/or group constraints
+#' @author Ross Bennett
+#' @export
+turnover_constraint <- function(type, max.turnover, enabled=FALSE, ...){
+  Constraint <- constraint_v2(type, ...)
+  Constraint$toc <- max.turnover
+  return(Constraint)
+}
+
 #' function for updating constrints, not well tested, may be broken
 #' 
 #' can we use the generic update.default function?



More information about the Returnanalytics-commits mailing list