box_constraint: constructor for box_constraint.

View source: R/constraints.R

box_constraintR Documentation

constructor for box_constraint.

Description

Box constraints specify the upper and lower bounds on the weights of the assets. This function is called by add.constraint when type="box" is specified. See add.constraint.

Usage

box_constraint(
  type = "box",
  assets,
  min,
  max,
  min_mult,
  max_mult,
  enabled = TRUE,
  message = FALSE,
  ...
)

Arguments

type

character type of the constraint

assets

number of assets, or optionally a named vector of assets specifying initial weights

min

numeric or named vector specifying minimum weight box constraints

max

numeric or named vector specifying minimum weight box constraints

min_mult

numeric or named vector specifying minimum multiplier box constraint from initial weight in assets

max_mult

numeric or named vector specifying maximum multiplier box constraint from initial weight in assets

enabled

TRUE/FALSE

message

TRUE/FALSE. The default is message=FALSE. Display messages if TRUE.

...

any other passthru parameters to specify box constraints

Value

an object of class 'box_constraint'

Author(s)

Ross Bennett

See Also

add.constraint

Examples

data(edhec)
ret <- edhec[, 1:4]

pspec <- portfolio.spec(assets=colnames(ret))

# defaults to min=0 and max=1
pspec <- add.constraint(pspec, type="box")

# specify box constraints as a scalar
pspec <- add.constraint(pspec, type="box", min=0.05, max=0.45)

# specify box constraints per asset
pspec <- add.constraint(pspec, 
                        type="box", 
                        min=c(0.05, 0.10, 0.08, 0.06), 
                        max=c(0.45, 0.55, 0.35, 0.65))
                        

braverock/PortfolioAnalytics documentation built on April 18, 2024, 4:09 a.m.