Open sstoeckl opened 6 years ago
I just realized that this happens if no weight (box) constraints are specified for the portfolio object. In this case generatesequence()
returns an error. A solution could be to assume any weight bound (e.g. min=-n_assets,max=+n_assets) and give a warning. However, when I try to add something like this:
if(min(constraints$min)==-Inf){ constraints$min <- rep(-nassets,nassets) warning("random_portfolio needs to sample between bounded weights. As no box constraints were set, we specify minimum weights as -number of assets.") } if(max(constraints$max)==Inf){ constraints$max <- rep(nassets,nassets) warning("random_portfolio needs to sample between bounded weights. As no box constraints were set, we specify maximum weights as number of assets.") }
I get various other problems in rp_transform
not finding feasible weights etc...
Did you resolve this issue? I am having a similar problem.
See the code below. Is that intended?
Created on 2018-09-20 by the reprex package (v0.2.1.9000)