Hauptinhalt

Estimate Expected Shortfall for Asset Portfolios

This example shows how to compute the expected shortfall (ES) for a portfolio of equity positions. ES is a market risk metric that supplements a calculated value-at-risk (VaR) value. For an example of ES computation on a single market index, see Expected Shortfall Estimation and Backtesting. The 95% VaR represents the threshold loss amount that is only violated about 5% of the time, while ES is an estimate of the average amount of money the portfolio loses on the 5% of days when the VaR is violated.

Since ES values are used as a supplement to a given VaR model, this example begins by calculating a set of VaR values. For more details about calculating VaR on a portfolio of equity positions, see Estimate VaR for Equity Portfolio Using Parametric Methods. In this example, the VaR values are calculated using the exponentially weighted moving average (EWMA) approach discussed in Estimate VaR for Equity Portfolio Using Parametric Methods. This example assumes that the portfolio returns are normally distributed.

VaR Calculation

To calculate a VaR, load the data, calculate the returns, and set the window variables for the rolling data window.

% Load equity prices
equityPrices = load("SharePrices.mat","data");
equityPrices = equityPrices.data;

returns = tick2ret(equityPrices);

sampleSize = length(returns);
windowSize = 250;
testWindowSize = sampleSize-windowSize;

Load an equity portfolio to analyze. Then, calculate the dollar value of exposure to each stock.

% Load simulatd equity portfolio
numShares = load("SimulatedRiskParityPortfolio.mat","RiskParityPortfolio");
numShares = numShares.RiskParityPortfolio;

% Dollar value of exposure to each stock
V = equityPrices(windowSize+1:end-1,:).*numShares;

Initialize the σportfolio and profit and loss (P&L) vectors, which will be used for backtesting in ES Backtest.

% VaR confidence level
VaRLevel = 0.95;

% Initialize portfolioSigmas and P&L answer vectors
ewmaPortfolioSigmas = zeros(testWindowSize,1);
portfolioPandL = zeros(testWindowSize,1);

For each trading day, calculate the covariances of the returns and the amount invested in each asset. (For more information on this process, see Estimate VaR for Equity Portfolio Using Parametric Methods.) Also, save σportfolio and P&L values for each day. After the loop use the σportfolio values to calculate VaR estimates for each day in the test window.

% t is the index number within the estimation window,
% k is the index number within the entire data set.
for t = 1:testWindowSize
    k = windowSize + t;

    % Calculate covariance Matrix
    covMatrixData = returns(t:k-1,:);

    % Using ewstats to compute exponentially weighted covariance matrix.
    lambda = 0.94;
    [~,ewmaCovMatrix] = ewstats(covMatrixData,lambda,windowSize);

    % Calculate the standard deviation of the portfolio returns.
    v = V(t,:);
    ewmaPortfolioSigmas(t) = sqrt(v*ewmaCovMatrix*v');

    % Save P&L values
    portfolioPandL(t) = sum(returns(k,:).*v);
end

% Calculate VaR values
ewma95 = valueAtRisk("normal",VaRLevel,"Mean",0,"StandardDeviation",ewmaPortfolioSigmas);

ES Calculation

Recall that the VaR for a given portfolio is the maximum amount of money a portfolio can lose and still be within a defined confidence level. A 95% VaR represents a threshold loss amount that should only be violated 5% of the time. One consequence of this definition is that the problem of calculating a VaR value reduces to estimating the portfolio returns distribution. Once the portfolio returns distribution is described with sufficient accuracy, possibly by estimating distribution parameters, then the VaR value is logically determined. This is why the valueAtRisk function requires distribution information to calculate a VaR value.

The ES value for a given portfolio is an estimate of the average amount of money the portfolio loses when the VaR is violated. This value, like the VaR, is also logically determined once the portfolio returns distribution has been established. The same inputs used to calculate a VaR value can also be used to calculate the associated ES value. Use the expectedShortfall function in the Risk Management Toolbox™ to estimate the ES for our portfolio. Note that the required function inputs for expectedShortfall are identical to those required for valueAtRisk. For more information about expected shortfall estimates, see Estimate Expected Shortfall with the expectedShortfall Function.

esEWMA95 = expectedShortfall("normal",VaRLevel,"Mean",0,"StandardDeviation",ewmaPortfolioSigmas);

ES Backtest

Validating the ES values requires backtesting the computed ES sequence. In the Risk Management Toolbox, you can do this using esbacktest or esbacktestbysim. For more information about ES backtesting, see Overview of Expected Shortfall Backtesting. To use esbacktest, pass the function the P&L values, VaR values, and ES values. Then use the summary and runtests functions with the resulting esbacktest object.

ebt = esbacktest(portfolioPandL,ewma95,esEWMA95,"VaRLevel",0.95);

summaryTable = summary(ebt)
summaryTable=1×11 table
    PortfolioID    VaRID    VaRLevel    ObservedLevel    ExpectedSeverity    ObservedSeverity    Observations    Failures    Expected    Ratio     Missing
    ___________    _____    ________    _____________    ________________    ________________    ____________    ________    ________    ______    _______

    "Portfolio"    "VaR"      0.95         0.9096             1.254               1.4181             531            48        26.55      1.8079       0   

testsTable = runtests(ebt,"ShowDetails",true)
testsTable=1×6 table
    PortfolioID    VaRID    VaRLevel    UnconditionalNormal    UnconditionalT    TestLevel
    ___________    _____    ________    ___________________    ______________    _________

    "Portfolio"    "VaR"      0.95            reject               reject          0.95   

The esbacktest function has two tests, the unconditional normal and t tests. esbacktest does not require any information about the portfolio return distribution, which makes it a flexible tool for evaluating ES performance, even for methods that do not assume an explicit form for the portfolio returns' distribution. However, esbacktest is also relatively limited in terms of accuracy.

In this case, the VaR and ES calculations leverage explicit distributional assumptions, and you compute parameters to match those assumptions. It is best to use esbacktestbysim because this function runs a comprehensive suite of tests on the ES data. esbacktestbysim takes the same inputs as esbacktest, along with distribution information (esbacktestbysim only supports normal, t, and empirical distributions). You can use esbacktestbysim to simulate a set of portfolio returns that you can compare against the actual portfolio and ES data using a variety of test metrics.

ebtSim = esbacktestbysim(portfolioPandL,ewma95,esEWMA95,"normal",'StandardDeviation',ewmaPortfolioSigmas,'mean',0,'VaRLevel',0.95);

rng(1,"twister");
simSummary = summary(ebtSim)
simSummary=1×11 table
    PortfolioID    VaRID    VaRLevel    ObservedLevel    ExpectedSeverity    ObservedSeverity    Observations    Failures    Expected    Ratio     Missing
    ___________    _____    ________    _____________    ________________    ________________    ____________    ________    ________    ______    _______

    "Portfolio"    "VaR"      0.95         0.9096             1.254               1.4181             531            48        26.55      1.8079       0   

simTests = runtests(ebtSim,'ShowDetails',true)
simTests=1×9 table
    PortfolioID    VaRID    VaRLevel    Conditional    Unconditional    Quantile    MinBiasAbsolute    MinBiasRelative    TestLevel
    ___________    _____    ________    ___________    _____________    ________    _______________    _______________    _________

    "Portfolio"    "VaR"      0.95        reject          reject         reject         reject             reject           0.95   

The computed ES values do not match the actual portfolio performance, suggesting the distribution assumptions are inadequate. The Estimate VaR for Equity Portfolio Using Parametric Methods has a similar result with the same portfolio, but with VaR backtesting instead of ES backtesting. The issue in both cases is the assumption that the portfolio returns are normally distributed, while actual financial data has fatter tails. Two possible alternatives are:

  • Use a different parametric method. Modeling the portfolio returns with a t-distribution, results in fatter tails than with the normal distribution. You can replace the standard deviation parameter with a scale parameter, then proceed to compute the VaR and ES values with valueAtRisk and expectedShortfall as above. The function calls for a t-distribution require an estimate for the degrees of freedom in addition to the scale parameter. For an example of ES calculation with a t-distribution, see Expected Shortfall Estimation and Backtesting.

  • Use a nonparametric method to calculate the portfolio VaR and ES by using a historical VaR method. For an example of calculating a historical ES, see Expected Shortfall Estimation and Backtesting.

See Also

| | |

Topics