0
$\begingroup$

I am trying to implement a max return optimization with a large number of assets. I am not sure why this problem won't work.

w = cvxpy.Variable(num_asset) #30 assets
constraints = []
constraints.append(cvxpy.abs(w) <= 1)
constraints.append(cvxpy.sum_entries(w) == 1)
objective = cvxpy.Maximize(combined_return.T * w - 0.5 * alpha * cvxpy.quad_form(w, combined_covariance))
problem = cvxpy.Problem(objective)
problem.solve(solver='CVXOPT', verbose=True)

The result have 3 of the weights way greater than 1.

          Holding
PCLN     0.024891
MHK      0.005428
**AZO    -14.429484**
SJM      0.006767
COST     0.027336
CLX      0.006752
TSO      0.003282
VLO      0.008457
PSX      0.014839
BLK      0.021508
ICE      0.011146
EQR      0.009720
ISRG     0.009747
BIIB     0.020765
GILD     0.043480
UAL      0.005269
GWW      0.005330
LMT      0.028927
**GOOGL   14.624353**
GOOG     0.182734
**IBM    121.617234**
SHW      0.010577
LYB      0.012353
EMN      0.003821
LVLT     0.007118
VZ       0.085949
T        0.098943
NEE      0.022617
SRE      0.010750
AEP      0.013104

Could someone help me understand why that constraint cvxpy.abs(w)<=1 doesn't do the job? Many thanks

$\endgroup$
  • $\begingroup$ Shouldn't you include constraints as a parameter to the call to Problem? $\endgroup$ – Bob Jansen Nov 13 '16 at 16:06
1
$\begingroup$

You forgot to include constraints as a parameter to the call to Problem.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.