Session Ready
Exercise

Minimizing CVaR

This exercise will give you practice with PyPortfolioOpt's tools for CVaR minimization as a risk management objective.

You'll load the pypfopt.efficient_frontier module and retrieve the EfficientFrontier class, creating an instance of the class using the investment bank assets over the 2005 - 2010 period. You'll also load the negative_cvar() function from the pypfopt.objective_functions module.

You'll then use the EfficientFrontier.custom_objective() method with negative_cvar() to find the optimal portfolio weights that minimize the CVaR.

Portfolio asset returns are in the returns vector, and the efficient covariance matrix is in e_cov.

Instructions
100 XP
  • Import the EfficientFrontier class from pypfopt.efficient_frontier.
  • Import the negative_cvar function from pypfopt.objective_functions.
  • Create the EfficientFrontier class instance ef using e_cov; note you don't need expected returns, since the objective function is different from mean-variance optimization.
  • Find and display the optimal portfolio using ef's .custom_objective() method and the negative_cvar function.