Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

position_limit_constraint

constructor for position_limit_constraint


Description

This function is called by add.constraint when type="position_limit" is specified, add.constraint Allows the user to specify the maximum number of positions (i.e. number of assets with non-zero weights) as well as the maximum number of long and short positions.

Usage

position_limit_constraint(type = "position_limit", assets, max_pos = NULL,
  max_pos_long = NULL, max_pos_short = NULL, enabled = TRUE,
  message = FALSE, ...)

Arguments

type

character type of the constraint

assets

named vector of assets specifying initial weights

max_pos

maximum number of assets with non-zero weights

max_pos_long

maximum number of assets with long (i.e. buy) positions

max_pos_short

maximum number of assets with short (i.e. sell) positions

enabled

TRUE/FALSE

message

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

...

any other passthru parameters to specify position limit constraints

Value

an object of class 'position_limit_constraint'

Author(s)

Ross Bennett

See Also

Examples

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

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

pspec <- add.constraint(portfolio=pspec, type="position_limit", max_pos=3)
pspec <- add.constraint(portfolio=pspec, type="position_limit", max_pos_long=3, max_pos_short=1)

PortfolioAnalytics

Portfolio Analysis, Including Numerical Methods for Optimization of Portfolios

v1.1.0
GPL-2 | GPL-3
Authors
Brian G. Peterson [cre, aut, cph], Peter Carl [aut, cph], Kris Boudt [ctb, cph], Ross Bennett [ctb, cph], Hezky Varon [ctb], Guy Yollin [ctb], R. Douglas Martin [ctb]
Initial release
2018-05-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.