I am trying to implement the Sharpe's return-based style analysis on Python. The problem is formulated as follows:
min Var(M-(c1a1 + c2a2 + c3a3 + c4a4)) subject to c1 + c2 + c3 + c4 = 1 c1 >=0, c2 >= 0, c3 >= 0, c4 >= 0 where M = monthly or daily return of an investor's portfolio a1, a2, a3, a4 = monthly or daily return of an index and c1, c2, c4, c4 are the optimization decision variables.
Of course, the objective function (Variance) makes the problem nonlinear. I am trying to use Scipy to implement this, but I cannot find a good example of quadratic/nonlinear optimization similar to this problem.
What Python library should I use to do this? The example above has only 4 indices, but I want to make it more general and flexible as to handle many indices.
I would also very appreciate it if someone could show a Python code for the optimization problem above.