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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 23 03:04:45 CEST 2013


Author: rossbennett34
Date: 2013-07-23 03:04:44 +0200 (Tue, 23 Jul 2013)
New Revision: 2632

Added:
   pkg/PortfolioAnalytics/man/constraint_v1.Rd
Modified:
   pkg/PortfolioAnalytics/NAMESPACE
   pkg/PortfolioAnalytics/R/constraints.R
   pkg/PortfolioAnalytics/man/constraint.Rd
Log:
updating constraints to alias constraint_v2 to constraint and use constraint inside functions

Modified: pkg/PortfolioAnalytics/NAMESPACE
===================================================================
--- pkg/PortfolioAnalytics/NAMESPACE	2013-07-23 00:49:03 UTC (rev 2631)
+++ pkg/PortfolioAnalytics/NAMESPACE	2013-07-23 01:04:44 UTC (rev 2632)
@@ -15,6 +15,7 @@
 export(constrained_objective_v2)
 export(constrained_objective)
 export(constraint_ROI)
+export(constraint_v1)
 export(constraint_v2)
 export(constraint)
 export(diversification_constraint)

Modified: pkg/PortfolioAnalytics/R/constraints.R
===================================================================
--- pkg/PortfolioAnalytics/R/constraints.R	2013-07-23 00:49:03 UTC (rev 2631)
+++ pkg/PortfolioAnalytics/R/constraints.R	2013-07-23 01:04:44 UTC (rev 2632)
@@ -25,7 +25,7 @@
 #' @examples 
 #' exconstr <- constraint(assets=10, min_sum=1, max_sum=1, min=.01, max=.35, weight_seq=generatesequence())
 #' @export
-constraint <- function(assets=NULL, ... ,min,max,min_mult,max_mult,min_sum=.99,max_sum=1.01,weight_seq=NULL)
+constraint_v1 <- function(assets=NULL, ... ,min,max,min_mult,max_mult,min_sum=.99,max_sum=1.01,weight_seq=NULL)
 { # based on GPL R-Forge pkg roi by Stefan Thuessel,Kurt Hornik,David Meyer
   if (hasArg(min) & hasArg(max)) {
     if (is.null(assets) & (!length(min)>1) & (!length(max)>1)) {
@@ -159,6 +159,8 @@
 #' @param ... any other passthru parameters
 #' @param constrclass character to name the constraint class
 #' @author Ross Bennett
+#' @aliases constraint
+#' @rdname constraint
 #' @export
 constraint_v2 <- function(type, enabled=TRUE, ..., constrclass="v2_constraint"){
   if(!hasArg(type)) stop("you must specify a constraint type")
@@ -173,6 +175,10 @@
   )
 }
 
+# Alias constraint_v2 to constraint
+#' @export
+constraint <- constraint_v2
+
 #' General interface for adding and/or updating optimization constraints.
 #' 
 #' This is the main function for adding and/or updating constraints in an object of type \code{\link{portfolio}}.
@@ -386,7 +392,7 @@
     max[which(tmp_max < max)] <- tmp_max[which(tmp_max < max)]
   }
   
-  Constraint <- constraint_v2(type=type, enabled=enabled, constrclass="box_constraint", ...)
+  Constraint <- constraint(type=type, enabled=enabled, constrclass="box_constraint", ...)
   Constraint$min <- min
   Constraint$max <- max
   return(Constraint)
@@ -462,7 +468,7 @@
     }
   }
   
-  Constraint <- constraint_v2(type, enabled=enabled, constrclass="group_constraint", ...)
+  Constraint <- constraint(type, enabled=enabled, constrclass="group_constraint", ...)
   Constraint$groups <- groups
   Constraint$group_labels <- group_labels
   Constraint$cLO <- group_min
@@ -506,7 +512,7 @@
 #' pspec <- add.constraint(pspec, type="active")
 #' @export
 weight_sum_constraint <- function(type, min_sum=0.99, max_sum=1.01, enabled=TRUE, ...){
-  Constraint <- constraint_v2(type, enabled=enabled, constrclass="weight_sum_constraint", ...)
+  Constraint <- constraint(type, enabled=enabled, constrclass="weight_sum_constraint", ...)
   Constraint$min_sum <- min_sum
   Constraint$max_sum <- max_sum
   return(Constraint)
@@ -627,7 +633,7 @@
 #' pspec <- add.constraint(portfolio=pspec, type="turnover", turnover_target=0.6)
 #' @export
 turnover_constraint <- function(type, turnover_target, enabled=TRUE, message=FALSE, ...){
-  Constraint <- constraint_v2(type, enabled=enabled, constrclass="turnover_constraint", ...)
+  Constraint <- constraint(type, enabled=enabled, constrclass="turnover_constraint", ...)
   Constraint$turnover_target <- turnover_target
   return(Constraint)
 }
@@ -651,7 +657,7 @@
 #' pspec <- add.constraint(portfolio=pspec, type="diversification", div_target=0.7)
 #' @export
 diversification_constraint <- function(type, div_target, enabled=TRUE, message=FALSE, ...){
-  Constraint <- constraint_v2(type, enabled=enabled, constrclass="diversification_constraint", ...)
+  Constraint <- constraint(type, enabled=enabled, constrclass="diversification_constraint", ...)
   Constraint$div_target <- div_target
   return(Constraint)
 }
@@ -716,7 +722,7 @@
     # coerce to integer
     max_pos_short <- as.integer(max_pos_short)
   }
-  Constraint <- constraint_v2(type, enabled=enabled, constrclass="position_limit_constraint", ...)
+  Constraint <- constraint(type, enabled=enabled, constrclass="position_limit_constraint", ...)
   Constraint$max_pos <- max_pos
   Constraint$max_pos_long <- max_pos_long
   Constraint$max_pos_short <- max_pos_short

Modified: pkg/PortfolioAnalytics/man/constraint.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/constraint.Rd	2013-07-23 00:49:03 UTC (rev 2631)
+++ pkg/PortfolioAnalytics/man/constraint.Rd	2013-07-23 01:04:44 UTC (rev 2632)
@@ -1,47 +1,27 @@
-\name{constraint}
+\name{constraint_v2}
 \alias{constraint}
-\title{constructor for class constraint}
+\alias{constraint_v2}
+\title{constructor for class v2_constraint}
 \usage{
-  constraint(assets = NULL, ..., min, max, min_mult,
-    max_mult, min_sum = 0.99, max_sum = 1.01,
-    weight_seq = NULL)
+  constraint_v2(type, enabled = TRUE, ...,
+    constrclass = "v2_constraint")
 }
 \arguments{
+  \item{type}{character type of the constraint to add or
+  update, currently 'weight_sum', 'box', or 'group'}
+
   \item{assets}{number of assets, or optionally a named
   vector of assets specifying seed weights}
 
   \item{...}{any other passthru parameters}
 
-  \item{min}{numeric or named vector specifying minimum
-  weight box constraints}
-
-  \item{max}{numeric or named vector specifying minimum
-  weight box constraints}
-
-  \item{min_mult}{numeric or named vector specifying
-  minimum multiplier box constraint from seed weight in
-  \code{assets}}
-
-  \item{max_mult}{numeric or named vector specifying
-  maximum multiplier box constraint from seed weight in
-  \code{assets}}
-
-  \item{min_sum}{minimum sum of all asset weights, default
-  .99}
-
-  \item{max_sum}{maximum sum of all asset weights, default
-  1.01}
-
-  \item{weight_seq}{seed sequence of weights, see
-  \code{\link{generatesequence}}}
+  \item{constrclass}{character to name the constraint
+  class}
 }
 \description{
-  constructor for class constraint
+  constructor for class v2_constraint
 }
-\examples{
-exconstr <- constraint(assets=10, min_sum=1, max_sum=1, min=.01, max=.35, weight_seq=generatesequence())
-}
 \author{
-  Peter Carl and Brian G. Peterson
+  Ross Bennett
 }
 

Added: pkg/PortfolioAnalytics/man/constraint_v1.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/constraint_v1.Rd	                        (rev 0)
+++ pkg/PortfolioAnalytics/man/constraint_v1.Rd	2013-07-23 01:04:44 UTC (rev 2632)
@@ -0,0 +1,47 @@
+\name{constraint_v1}
+\alias{constraint_v1}
+\title{constructor for class constraint}
+\usage{
+  constraint_v1(assets = NULL, ..., min, max, min_mult,
+    max_mult, min_sum = 0.99, max_sum = 1.01,
+    weight_seq = NULL)
+}
+\arguments{
+  \item{assets}{number of assets, or optionally a named
+  vector of assets specifying seed weights}
+
+  \item{...}{any other passthru parameters}
+
+  \item{min}{numeric or named vector specifying minimum
+  weight box constraints}
+
+  \item{max}{numeric or named vector specifying minimum
+  weight box constraints}
+
+  \item{min_mult}{numeric or named vector specifying
+  minimum multiplier box constraint from seed weight in
+  \code{assets}}
+
+  \item{max_mult}{numeric or named vector specifying
+  maximum multiplier box constraint from seed weight in
+  \code{assets}}
+
+  \item{min_sum}{minimum sum of all asset weights, default
+  .99}
+
+  \item{max_sum}{maximum sum of all asset weights, default
+  1.01}
+
+  \item{weight_seq}{seed sequence of weights, see
+  \code{\link{generatesequence}}}
+}
+\description{
+  constructor for class constraint
+}
+\examples{
+exconstr <- constraint(assets=10, min_sum=1, max_sum=1, min=.01, max=.35, weight_seq=generatesequence())
+}
+\author{
+  Peter Carl and Brian G. Peterson
+}
+



More information about the Returnanalytics-commits mailing list