Question: Maximize Risk Adjusted Return in QP Matrix Form

Ok, first of all I renamed the return matrix R (A is allready used)
I now think I got two of them (minimize portfolio variance and minimize portfolio variance for a
given expected return in matrix form) figured out:


Cov := Matrix(CovarianceMatrix(R), datatype = float):
pr := .6*max([seq(ExpectedValue(Column(R, i)), i = 1 .. nstock)]):

A := Matrix([[seq(1, i = 1 .. nstock)]], datatype = float):
b := Vector([1], datatype = float):
Aeq := Matrix([seq(ExpectedValue(Column(R, i)), i = 1 .. nstock)], datatype = float):
beq := Vector([pr], datatype = float):
bl := Vector([seq(0, i = 1 .. nstock)], datatype = float):
bu := Vector([seq(1, i = 1 .. nstock)], datatype = float):

st := time():

QPSolve(Cov, [A, b], [bl, bu]);                        # QP1 minimize portfolio variance
QPSolve(Cov, [A, b, Aeq, beq], [bl, bu]);          # QP2 minimize portfolio variance for a given expected return

'Time' = time()-st ;

# x := Vector([seq(w[i], i = 1 .. nstock)]):
# A.x # Aeq.x = beq    #  EV.W = pr:



            [                                            [ 1 .. 100 Vector[column] ]]
            [                                            [ Data Type: float[8]     ]]
            [3.94567847469744 10^-31,    [ Storage: rectangular    ]]
            [                                            [ Order: Fortran_order    ]]
         
              [                                     [ 1 .. 100 Vector[column] ]]
              [                                     [ Data Type: float[8]     ]]
              [0.611914499710515,       [ Storage: rectangular    ]]
              [                                     [ Order: Fortran_order    ]]
                               

                                   Time = 0.187

However, the allocations and portfolio variance are different from when you
express the problem algebraically. The variance is lower in matrix form, why is that?
Is it because the matrix-form solver is more efficient?



Cov := CovarianceMatrix(R):
EV := Vector([seq(ExpectedValue(Column(R, i)), i = 1 .. nstock)]):

W := Vector([seq(w[i], i = 1 .. nstock)]):
pr := .6*max([seq(ExpectedValue(Column(R, i)), i = 1 .. nstock)]):

con1 := add(W[i], i = 1 .. nstock) con2 := seq(W[i] con3 := seq(W[i] >= 0, i = 1 .. nstock):
con4 := EV.W = pr:

st := time():

data1 := QPSolve(Transpose(W).Cov.W, {con1, con2, con3});
data2 := QPSolve(Transpose(W).Cov.W, {con1, con2, con3, con4});

'Time' = time()-st


                             data11 := [0., []]
      data22 := [1.22382899942106, [w[7] = 0.0386284362797579272,

        w[9] = 0.0730394317974843998, w[10] = 0.0220290531819183622,

        w[23] = 0.0376963048118319420, w[26] = 0.0109056058516866888,

        w[36] = 0.0638868095121430946, w[42] = 0.443768526759315551,

        w[58] = 0.113704988162881368, w[59] = 0.0250063262537721896,

        w[87] = 0.0141634130614213018, w[88] = 0.118045894045597454,

        w[100] = 0.0299915954928384154]]


                           Time = 1.107


So my question now becomes how do you express the maximize risk adjusted returns  QPSolve(Transpose(W).Cov.W - Transpose(W).EV, {con1, con2, con3}); in matrix form?  

This has been branched into the following page(s):
Please Wait...