# Portfolio/sub-portfolio optimization

I have a finite amount of 26 assets, the total amount of these assets needs to be allocated to 9 portfolios. Each portfolio has its own required return which needs to be met, using a min-variance approach.

This is the optimization problem, subject to:
- Each asset should be 100% allocated
- Asset 1 and 2 are held constant (the sub-portfolios already holds some amount of these 26 assets)
- Asset 3 must not weigh more than 20% within each portfolio
- Asset 4 must not weigh more than 25% within each portfolio
- Each portfolio has a given AuM which the new allocation must equal
- No assets can have negative weight (long-only)

I have a dataset holding the 26 assets, expected returns and a covariance matrix.

I am able to optimize a single portfolio, the trick is when i want to optimize across the 9 portfolios.
I have been looking into quadratic programming as a means to this problem, if anyone are able to point me in the right direction, maybe some useful links or something. I am coding in Python, so Python solutions is a plus, but i also have access to R and MatLab.

You will need a weight for each of the 26 assets in each of the 9 portfolios. Suppose you take each portfolio in turn and create a stacked vector:

$$\mathbf{w} = [w_{1,1} \; .. \;w_{1,26} \; w_{2,1} \; .. \; w_{2,26} \; .. \;w_{9,26}]$$

# Equality constraints:

• Each weight of an asset cross section has to sum to the holding, $$W_j$$:

$$\sum_{i=1}^9 w_{i,j} = W_j \quad \forall \quad \text{assets }j$$

This is also easily expressed in matrix-vector notation,e.g. for a 2 portfolio x 3 assets:

$$\begin{bmatrix} 1 & 0 & 0 & 1 & 0 & 0 \\ 0 & 1 & 0 & 0 & 1 & 0 \\ 0 & 0 & 1 & 0 & 0 & 1 \end{bmatrix} \mathbf{w}= \begin{bmatrix} W_1 \\ W_2 \\ W_3 \end{bmatrix}$$

• Each portfolio has a specified AuM:

$$\begin{bmatrix} 1 & 1 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 1 & 1 \end{bmatrix} \mathbf{w}= \begin{bmatrix} AUM_1 \\ AUM_2\end{bmatrix}$$

Note these two constraints assume: $$\sum_{asset} W_{asset} = \sum_{portfolio} AUM_{portfolio}$$

• Some portfolios have required (achievable) returns, e.g. portfolio 2:

$$\begin{bmatrix} 0 & 0 & 0 & u_1 & u_2 & u_3 \\ \end{bmatrix} \mathbf{w} =U_2$$

# Inequality constraints:

• Long only:

$$-\mathbf{I} \mathbf{w} \leq \mathbf{0}$$

• Asset 4 cannot weight more than 25% in portfolio 2:

$$w_{2,2} \leq 0.25 \left ( w_{2,1} + w_{2,2} + w_{2,3} \right )$$

$$\begin{bmatrix} 0 & 0 & 0 & -0.25 & (1-0.25) & -0.25 \\ \end{bmatrix} \mathbf{w} \leq 0$$

# Objective Function

I suppose you are now doing the traditional Variance-Return optimisation

$$f(w) = \frac{1}{2}\mathbf{w^T 2\Sigma_p w} - \lambda \mathbf{u^T_p} \mathbf{w}$$

where $$\mathbf{\Sigma_p} = \begin{bmatrix} \Sigma & 0 & ... & 0 \\ 0 & \Sigma & .. & 0 \\ ... \\ 0 & 0 & .. & \Sigma \end{bmatrix}$$

and $$\mathbf{u^T_p} = [ \mathbf{u^T u^T .. u^T ]}$$

You could also tweak the $$\lambda$$ to impact individual portfolios rather than being a global risk-aversion parameter.

# Implementation

You can use the library cvxopt (https://cvxopt.org/userguide/coneprog.html#quadratic-programming) in python to solve this and the above formulations are organised to be directly compatible with the format.