How it works...
As mentioned in the introduction, we continued the example from the previous two recipes. That is why we had to run Step 1 to 4 from the Finding the Efficient Frontier using Monte Carlo simulations recipe (not shown here for brevity) to have all the required data. As an extra step, we had to import the cvxpy convex optimization library. We additionally converted the historical average returns and the covariance matrix into numpy arrays.
In Step 5, we set up the optimization problem. We started by defining the target variables (weights), the risk-aversion parameter gamma, the portfolio returns and volatility (both using the previously defined weights variable), and lastly, the objective function—the risk-adjusted returns we ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access