Suppose I have weights

 6.250000e-02  1.250000e-01  1.250000e-01 -9.375000e-02
-6.250000e-02 -1.250000e-01  1.562500e-01  9.375000e-02
 1.562500e-01  3.125000e-01  3.125000e-01 -3.125000e-02
-5.421011e-18 -6.250000e-02 -9.375000e-02  1.250000e-01

Now the sum of all these weights is 1, but I want to add a constraint that the minimum weight should be 0.02 and max 0.20 and also the sum should be one

Can anyone help?

I code in R and have got the weights by making a portfolio optimization without using fportfolio or portfolioAnalytics

  • $\begingroup$ A solution could be to use a coordinate transform method i.e. $w^* = \tan\left( \frac{(w-l)\pi}{u-l} - \frac{\pi}{2} \right)$ where $w$ is the original weight variable, $l$ lower bound, $u > l$ upper bound. The idea is then to optimise over $w^*$ (expressing $w$ as a function of $w^*$ in your objective function), finding the optimal $w^*$ and convert it back to $w$ which, by construction, will lie in $[l, u]$. $\endgroup$ – Quantuple Mar 3 '17 at 8:50
  • $\begingroup$ So you want optimization with inequality constraints - read e.g. www1.maths.leeds.ac.uk/~cajones/math2640/notes4.pdf $\endgroup$ – rbm Mar 3 '17 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.