January 2020
Beginner to intermediate
432 pages
11h 24m
English
Execute the following steps to find the Efficient Frontier using convex optimization.
import cvxpy as cp
avg_returns = avg_returns.valuescov_mat = cov_mat.values
weights = cp.Variable(n_assets)gamma = cp.Parameter(nonneg=True)portf_rtn_cvx = avg_returns * weights portf_vol_cvx = cp.quad_form(weights, cov_mat)objective_function = cp.Maximize(portf_rtn_cvx - gamma * portf_vol_cvx)problem = cp.Problem(objective_function, [cp.sum(weights) == 1, weights >= 0])
N_POINTS = 25portf_rtn_cvx_ef = np.zeros(N_POINTS)portf_vol_cvx_ef = np.zeros(N_POINTS)weights_ef ...
Read now
Unlock full access