I am trying to implement a simple min variance portfolio optimisation with a few simple constraints, long-only, sums to one. I also want to constraint on my betas to create a market neutral portfolio, i.e sum(betas) = 0. I am not very experienced with cvxpy but I quite like it and want to implement my stuff with it going forward. As an example( from the cvxpy website), which uses $$Min_x\;\; \frac{1}{2}x^T\Sigma x$$ Under the constraints $$x^T \mathbb{1}=1$$ $$\mu^Tx \geq \tau$$ I now want to add $$B^Tx=0$$ The constraint $B^Tx=0$ will ensure that the portfolios beta is zero. from cvxpy import * np.random.seed(1) n = 10 Sigma = np.random.randn(n, n) Sigma = Sigma.T.dot(Sigma) betas = [random.uniform(-1,1) for _ in range(10)] w = Variable(n) risk = quad_form(w, Sigma) constraints = [sum_entries(w) == 1, w >= 0] prob = Problem(Minimize(risk), constraints) for i in range(100): prob.solve() print('Weights :', w.value) How can I define the additional variable for beta and how do you alter your constraints list. From the manual I assume we need s.th in the form a quad_form(), but does this have to be defines similar to the risk variable in the example or inside the constraints object, and how do you link it to the betas data vector ? I would have done s.th like sum(quad_form(w, betas)) == 0 inside the constraints object which unfortunately doesn't work.