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.
Cet exercice fait partie du cours
Introduction to Portfolio Risk Management in Python
Instructions
- Calculate the average of returns in
StockReturns_percwhereStockReturns_percis less than or equal tovar_95and assign it tocvar_95. - Plot the histogram of sorted returns (
sorted_rets) using theplt.hist()function.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Historical CVaR 95
cvar_95 = ____
print(cvar_95)
# Sort the returns for plotting
sorted_rets = sorted(StockReturns_perc)
# Plot the probability of each return quantile
____(____, density=True, stacked=True)
# Denote the VaR 95 and CVaR 95 quantiles
plt.axvline(x=var_95, color="r", linestyle="-", label='VaR 95: {0:.2f}%'.format(var_95))
plt.axvline(x=cvar_95, color='b', linestyle='-', label='CVaR 95: {0:.2f}%'.format(cvar_95))
plt.show()