Hi Q,
I have the following maximisation currently that I want to port to optimize API. Could you please tell me how to go about it?
def trade(context, data):
stocks, alphas, betas, components = build_model(......)
(n,m) = betas.shape
x = cvx.Variable(n)
obj = cvx.Maximize(alphas.T * x)
constraints = [ sum(cvx.abs(x)) <= 1.,
cvx.abs(sum(x)) < 0.01 ]
c = components
constraints.append(cvx.abs(x - betas * (c * x)) < 0.001) # how do I do this with optimize API?
if context.prevX is not None:
constraints.append(sum(cvx.abs(x-context.prevX])) < 0.5) # turnover constraint
prob = cvx.Problem(obj, constraints)
prob.solve()
x = np.ravel(x.value)
# now we trade x weights
Best regards,
Pravin