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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jul 31 18:54:17 CEST 2013


Author: rossbennett34
Date: 2013-07-31 18:54:17 +0200 (Wed, 31 Jul 2013)
New Revision: 2684

Modified:
   pkg/PortfolioAnalytics/DESCRIPTION
   pkg/PortfolioAnalytics/NAMESPACE
   pkg/PortfolioAnalytics/R/constraints.R
   pkg/PortfolioAnalytics/man/constraint.Rd
Log:
modifying constraints and removing alias to maintain backwards compatibility with v1 constraint

Modified: pkg/PortfolioAnalytics/DESCRIPTION
===================================================================
--- pkg/PortfolioAnalytics/DESCRIPTION	2013-07-31 16:08:56 UTC (rev 2683)
+++ pkg/PortfolioAnalytics/DESCRIPTION	2013-07-31 16:54:17 UTC (rev 2684)
@@ -46,3 +46,4 @@
     'constraintsFUN.R'
     'constraint_fn_map.R'
     'optFUN.R'
+    'charts.ROI.R'

Modified: pkg/PortfolioAnalytics/NAMESPACE
===================================================================
--- pkg/PortfolioAnalytics/NAMESPACE	2013-07-31 16:08:56 UTC (rev 2683)
+++ pkg/PortfolioAnalytics/NAMESPACE	2013-07-31 16:54:17 UTC (rev 2684)
@@ -5,17 +5,19 @@
 export(box_constraint)
 export(CCCgarch.MM)
 export(chart.Scatter.DE)
+export(chart.Scatter.ROI)
 export(chart.Scatter.RP)
 export(chart.Weights.DE)
+export(chart.Weights.ROI)
 export(chart.Weights.RP)
 export(charts.DE)
+export(charts.ROI)
 export(charts.RP)
 export(constrained_group_tmp)
 export(constrained_objective_v1)
 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-31 16:08:56 UTC (rev 2683)
+++ pkg/PortfolioAnalytics/R/constraints.R	2013-07-31 16:54:17 UTC (rev 2684)
@@ -25,7 +25,7 @@
 #' @examples 
 #' exconstr <- constraint(assets=10, min_sum=1, max_sum=1, min=.01, max=.35, weight_seq=generatesequence())
 #' @export
-constraint_v1 <- function(assets=NULL, ... ,min,max,min_mult,max_mult,min_sum=.99,max_sum=1.01,weight_seq=NULL)
+constraint <- 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)) {
@@ -176,8 +176,8 @@
 }
 
 # Alias constraint_v2 to constraint
-#' @export
-constraint <- constraint_v2
+# @export
+# constraint <- constraint_v2
 
 #' General interface for adding and/or updating optimization constraints.
 #' 
@@ -397,7 +397,7 @@
     max[which(tmp_max < max)] <- tmp_max[which(tmp_max < max)]
   }
   
-  Constraint <- constraint(type=type, enabled=enabled, constrclass="box_constraint", ...)
+  Constraint <- constraint_v2(type=type, enabled=enabled, constrclass="box_constraint", ...)
   Constraint$min <- min
   Constraint$max <- max
   return(Constraint)
@@ -473,7 +473,7 @@
     }
   }
   
-  Constraint <- constraint(type, enabled=enabled, constrclass="group_constraint", ...)
+  Constraint <- constraint_v2(type, enabled=enabled, constrclass="group_constraint", ...)
   Constraint$groups <- groups
   Constraint$group_labels <- group_labels
   Constraint$cLO <- group_min
@@ -531,7 +531,7 @@
            min_sum <- 0
          }
   )
-  Constraint <- constraint(type, enabled=enabled, constrclass="weight_sum_constraint", ...)
+  Constraint <- constraint_v2(type, enabled=enabled, constrclass="weight_sum_constraint", ...)
   Constraint$min_sum <- min_sum
   Constraint$max_sum <- max_sum
   return(Constraint)
@@ -652,7 +652,7 @@
 #' pspec <- add.constraint(portfolio=pspec, type="turnover", turnover_target=0.6)
 #' @export
 turnover_constraint <- function(type="turnover", turnover_target, enabled=TRUE, message=FALSE, ...){
-  Constraint <- constraint(type, enabled=enabled, constrclass="turnover_constraint", ...)
+  Constraint <- constraint_v2(type, enabled=enabled, constrclass="turnover_constraint", ...)
   Constraint$turnover_target <- turnover_target
   return(Constraint)
 }
@@ -676,7 +676,7 @@
 #' pspec <- add.constraint(portfolio=pspec, type="diversification", div_target=0.7)
 #' @export
 diversification_constraint <- function(type="diversification", div_target, enabled=TRUE, message=FALSE, ...){
-  Constraint <- constraint(type, enabled=enabled, constrclass="diversification_constraint", ...)
+  Constraint <- constraint_v2(type, enabled=enabled, constrclass="diversification_constraint", ...)
   Constraint$div_target <- div_target
   return(Constraint)
 }
@@ -741,7 +741,7 @@
     # coerce to integer
     max_pos_short <- as.integer(max_pos_short)
   }
-  Constraint <- constraint(type, enabled=enabled, constrclass="position_limit_constraint", ...)
+  Constraint <- constraint_v2(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-31 16:08:56 UTC (rev 2683)
+++ pkg/PortfolioAnalytics/man/constraint.Rd	2013-07-31 16:54:17 UTC (rev 2684)
@@ -1,12 +1,44 @@
-\name{constraint_v2}
+\name{constraint}
 \alias{constraint}
 \alias{constraint_v2}
-\title{constructor for class v2_constraint}
+\title{constructor for class 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{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{type}{character type of the constraint to add or
   update, currently 'weight_sum', 'box', or 'group'}
 
@@ -19,9 +51,16 @@
   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
 }
 



More information about the Returnanalytics-commits mailing list