Session Ready
Exercise

Historical expected shortfall

Expected Shortfall, otherwise known as CVaR, or conditional value at risk, is simply the expected loss of the worst case scenarios of returns.

For example, if your portfolio has a VaR(95) of -3%, then the CVaR(95) would be the average value of all losses exceeding -3%.

Returns data is available (in percent) in the variable StockReturns_perc. var_95 from the previous exercise is also available in your workspace.

Instructions
100 XP
  • Calculate the average of returns in StockReturns_perc where StockReturns_perc is less than or equal to var_95 and assign it to cvar_95.
  • Plot the histogram of sorted returns (sorted_rets) using the plt.hist() function.