1. Learn
  2. /
  3. Courses
  4. /
  5. Quantitative Risk Management in Python

Connected

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 EfficientCVaR class, creating an instance of the class using the investment bank assets over the 2005 - 2010 period.

You'll then use the instance's min_cvar() method to find the optimal portfolio weights that minimize the CVaR.

Portfolio asset returns are in the returns vector--this exercise also uses a names dictionary to map portfolio weights to bank names.

Instructions

100 XP
  • Import the EfficientCVaR class from pypfopt.efficient_frontier.
  • Create the EfficientCVaR class instance ec using returns; note you don't need expected_returns, since the objective function is different from mean-variance optimization.
  • Find and display the optimal portfolio using ec's .min_cvar() method.