# How to run optimization to achieve an equal active weight portfolio?

I am trying to build an equal active weight portfolio, while minimizing the total risk. However, my constraint of equal active weight always leads to 0 active weight for everything. I know 0 active weight for everything is not the optimal result, as there's no way my benchmark happens to be the minimal risk portfolio. Does anyone know how to solve this problem?

fun = lambda x: x.dot(covariance_matrix).dot(x.transpose())
cons = np.array([])

for i in range(0,x0.size-1):

con = {'type': 'eq', 'fun': lambda x, i=i: (x[i]-bmWeight[i])-(x[i+1]-bmWeight[i+1])}
cons = np.append(cons,con)

sumCon = {'type': 'eq', 'fun': lambda x:  sum(x)-1}
cons = np.append(cons, sumCon)

solution = minimize(fun,x0,method='SLSQP',constraints = cons)

• Your constraints simply $x_i - b_i = \frac{1}{n} \left( 1 - \sum_j b_j \right)$ for all $i$. This is zero if your $b$ weights sum to 1. – Matthew Gunn Sep 8 '17 at 1:38
• I'm voting to close this question as off-topic because the ratio between explanations and code is too low – lehalle Sep 10 '17 at 19:36

### Your constraints imply all the active weights must be zero!

We know that the base weights add to 1, that is:

$$\sum_i b_i = 1$$

Define the active weight $a_i$ as:

$$a_i = x_i - b_i$$

Hence if you have the constraint $\sum_i x_i = 1$, then the sum of the active weights must be zero. Observe that summing both sides:

$$\underbrace{\sum_i a_i}_{=0} = \underbrace{\sum_i x_i}_{=1} - \underbrace{\sum_i b_i}_{=1}$$.

Then if you add constraints such that $a_i = a_j$ for any $i$ and $j$ then $a_i = 0$ for all $i$ (otherwise, they wouldn't sum to zero).