Splitting Portfolio Weights into Positive and Negative Parts for QP
Summary
The document explains why a quadratic programming portfolio optimizer may use twice as many decision variables as there are assets. Each asset’s exposure is represented by a positive part and a nonpositive part, which together reconstruct the signed portfolio weight. This split can express absolute-value or long/short exposure limits through linear constraints, a form supported by linear-constraint QP solvers.
The objective must be reformulated along with the constraints. The block matrix shown in the question, with positive and negative covariance blocks, corresponds to expressing the risk quadratic in terms of the split variables. The example also describes separate bounds for buys and sells, with prior holdings used in the initial guess. The explanation gives the general transformation but does not cover solver-specific setup or all portfolio constraints. It also does not discuss possible non-uniqueness in the split representation when both parts are allowed to offset one another.
Key ideas
- Represent each signed asset weight as the sum of positive and nonpositive components.
- Splitting weights doubles the decision-variable count while enabling linear exposure constraints.
- Constraints on the original weight must be rewritten using the split components.
- The quadratic risk objective also needs matching positive and negative blocks.
- Initial values and bounds can encode prior holdings and separate buy and sell limits.
Tags
Full text
# quadratic programming portfolio optimisation
# quadratic programming portfolio optimisation
I am using MATLAB to do an optimisation. The QP minimisation problem is set up in the standard form shown below. The optimisation is used to calculate the weights (x vector in the equation below) of a portfolio.
```
Min 0.5 (x'Fx) + c'x
x
st
x_low <= x <= x_up
b_low <= Ax <= b_up
where
c is a n x 1 vector in the objective function
x is a n x 1 vector (weights of the stocks in the portfolio)
F is a n x n matrix in the objective function
A is the linear constraint matrix
b_low & up are the lower and upper bounds for the linear constraints
```
Trying to follow an example but have two issues. Firstly say the portfolio has 500 stocks the x vector passed into the optimiser (x here is our initial guess) will have the dimension of 1000 x 1. The second 500 will have the opposite sign of the first 500, I do not understand why this is?
Also the F matrix does something similar. Say I have a matrix R which contains some risk factors, which is 500 x 500.
Then F is set to the following (sorry not sure how to show matrices on this site properly)
```
F = R -R
-R R
```
Again why would you do this?
Update
The solver is actually Tomlab (user guide of the solve is here link).
Further Info
Just stepping through the code.
x0 is passed as an intial guess vector 1000 x 1. The first 500 weights are the previous weights. The next 500 weights are all set to zero.
x_up is obviously also a 1000 x 1 vector to. Looking further into the code. The first 500 weights are the upper bounds on the buys the next 500 are the upper bounds on the sells.
x_low is the same but for the lower bounds. First 500 weights are the lower bounds on the buys the next 500 are the lower bounds for the sales.
## Answer by vanguard2k (score 1, accepted)
https://quant.stackexchange.com/a/14917
OK one thing that comes to my mind is the standard trick to reformulate constraints like $|x_i|<=c$ (limiting exposure of $x_i$ while still allowing negative weights). Notice, that $|x_i| \leq c$ is not a linear constraint, so the solver wont work in this case. A little trick can help:
You split up the variables into positive and negative parts: $x_i=x_i^+ + x_i^-$ Now, by definition, $x_i^+ \geq 0$ and $x_i^-\leq 0$
now, notice that $|x_i|= x_i^+ - x_i^-$ and the constraint becomes linear:
$$ x_i^+ - x_i^- \leq c, \quad x_i^+ \geq 0, \quad x_i^-\leq 0$$
If you have other linear constraints for $x_i$, you simply plug in $x_i = x_i^+ + x_i^-$.
This method will double the dimensions but magically "linearises" the constraints. Of yourse, you need to reformulate the whole functional (for example $F = 1/2* (R,-R; -R,R)$ which almost corresponds to your observation)Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.