This function generates random portfolios based on the gridSearch
function from the 'NMOF' package.
rp_grid(portfolio, permutations = 2000, normalize = TRUE)
matrix of random portfolio weights
an object of class 'portfolio' specifying the constraints for the optimization, see portfolio.spec
integer: number of unique constrained random portfolios to generate
TRUE/FALSE to normalize the weghts to satisfy min_sum or max_sum
The number of levels is calculated based on permutations and number of assets. The number of levels must be an integer and may not result in the exact number of permutations. We round up to the nearest integer for the levels so the number of portfolios generated will be greater than or equal to permutations.
The grid search method only satisfies the min
and max
box
constraints. The min_sum
and max_sum
leverage constraints will
likely be violated and the weights in the random portfolios should be
normalized. Normalization may cause the box constraints to be violated and
will be penalized in constrained_objective
.