Here is the premise: I have a three asset portfolio, I know the assets covariance, the client's risk aversion and the expected return of one of the assets. I also have a desired set of weights.
So, 1) how do I find the expected returns for the two assets I don't know that gives me my desired set of weights and 2) if I reverse the function can I get the desired weights back i.e. test the results?
Here's my Python code:
import numpy as np
# Define the function
def get_weight(expected_return, asset_covariance, risk_aversion):
ER = expected_return
S = asset_covariance
L = risk_aversion
return np.linalg.inv(L * S) @ ER
# Given data
risk_aversion = 1.0 # example value for L
cov_matrix = np.array([[0.01, 0.002, 0.001], [0.002, 0.03, 0.004], [0.001, 0.004, 0.02]])
# example covariance matrix
# Desired weights
desired_weights = np.array([0, 0.55, 0.45])
# Solve for expected returns
expected_returns = risk_aversion * cov_matrix @ desired_weights
expected_returns[0] = 0.009 # given return
# Calculate weights using the original function
calculated_weights = get_weight(expected_returns, cov_matrix, risk_aversion)
# Output the results
expected_returns, calculated_weights
Here's the output I get. You clearly see it's not circular. I expect the weights array to be 0.00,0.55,0.45. I can understand some rounding but the result is quite a bit off.
Where am I going wrong? Please reference Python in your comments if you can.