rp_transform {PortfolioAnalytics} | R Documentation |
Transform a weights vector to satisfy constraints
Description
This function uses a block of code from randomize_portfolio
to transform the weight vector if either the weight_sum (leverage)
constraints, box constraints, group constraints, position_limit constraints,
or leverage exposure constraints are violated. The logic from
randomize_portfolio
is heavily utilized here with extensions to
handle more complex constraints.
The resulting weights vector might be quite different from the original weights vector.
Usage
rp_transform(
w,
min_sum,
max_sum,
min_box,
max_box,
groups = NULL,
cLO = NULL,
cUP = NULL,
max_pos = NULL,
group_pos = NULL,
max_pos_long = NULL,
max_pos_short = NULL,
leverage = NULL,
weight_seq = NULL,
max_permutations = 200
)
Arguments
w |
weights vector to be transformed |
min_sum |
minimum sum of all asset weights, default 0.99 |
max_sum |
maximum sum of all asset weights, default 1.01 |
min_box |
numeric or named vector specifying minimum weight box constraints |
max_box |
numeric or named vector specifying maximum weight box constraints |
groups |
vector specifying the groups of the assets |
cLO |
numeric or vector specifying minimum weight group constraints |
cUP |
numeric or vector specifying minimum weight group constraints |
max_pos |
maximum assets with non-zero weights |
group_pos |
vector specifying maximum number assets with non-zero weights per group |
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 |
leverage |
maximum leverage exposure where leverage is defined as |
weight_seq |
vector of seed sequence of weights |
max_permutations |
integer: maximum number of iterations to try for a valid portfolio, default 200 |
Value
named weighting vector
Author(s)
Peter Carl, Brian G. Peterson, Ross Bennett (based on an idea by Pat Burns)