I have the below function in Python. My objective is to back out the expected returns associated with certain portfolio weights given a series of assumptions.
From this I want to generate the expected returns I would get with a portfolio that has a number of constraints. My expectation is that I should get the same result from a function that is unconstrained and this one provided the weights I give both functions are within the same constraints and all other inputs are the same. But so far that isn't the case. Can anyone enlighten me on where I'm going wrong?
Constrained function (it isn't quite working):
def reverse_optimze_expected_return(weights, asset_covariance, weight_limits, risk_aversion):
n_assets = len(weights)
expected_return = cp.Variable(n_assets)
objective = cp.Minimize(cp.quad_form(weights, asset_covariance))
constraints = [
cp.sum(weights) == 1,
cp.quad_form(weights, asset_covariance) <= risk_aversion,
]
for i in range(n_assets):
constraints.append(weights[i] >= weight_limits[i][0] / 100)
constraints.append(weights[i] <= weight_limits[i][1] / 100)
problem = cp.Problem(objective, constraints)
problem.solve()
optimize_expected_returns = expected_return.value
return optimize_expected_returns
Here is the unconstrained function:
def get_expected_return(weight, asset_covariance, risk_aversion):
w = weight
S = asset_covariance
L = risk_aversion
return L * S @ w
weights are as follows [0.55, 0.45, 0.0]
asset_covariance is this matrix
risk_aversion is 3.1880326818259768
And weight_limits are [(42.5, 67.5), (32.5, 57.5), (0, 25)]