position_limit_constraint {PortfolioAnalytics} | R Documentation |
constructor for filter_constraint
Description
This function is called by add.constraint when type="filter" is specified, add.constraint
Usage
position_limit_constraint(
type = "position_limit",
filter_name = NULL,
enabled = TRUE,
message = FALSE,
...
)
Arguments
type |
character type of the constraint |
filter_name |
either a function to apply, or a name of a function to apply |
enabled |
TRUE/FALSE |
message |
TRUE/FALSE. The default is message=FALSE. Display messages if TRUE. |
... |
any other passthru parameters to specify position limit constraints |
Details
Allows the user to specify a filter function which will take returns, weights, and constraints as inputs, and can return a modified weights vector as output.
Fundamentally, it could be used to filter out certain assets, or to ensure that they must be long or short.
Typically, filter functions will be called by the random portfolio simulation function or via the fn_map function.
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)