I'm creating a long short market neutral portfolio using following function.
import cvxpy as cp
def create_gross_exposure_constraint(w):
return cp.norm1(w) <= 2
def create_market_neutral_constraint(w):
return cp.sum(w) == 0
I'm trying to add net asset value constraints as explained below:
I want the net exposure < 1 Million USD (this number can be changed). What does this mean is If i do allocation using above weight: abs(Position_of_Asset * Price_of_Asset) < 1 Million USD.
I tried creating it using below. But it is not working.
def create_value_exposure_constraint(w, idx):
x = cp.sum(cp.abs(w))
return w[idx] / x <= 0.1