Marginal Expected Shortfall (MES)
Calculate the Marginal Expected Shortfall (MES) of each ticker per period: its average return on the days the market (the benchmark) is in its worst alpha tail.
Acharya, Pedersen, Philippon and Richardson (2017) show that a financial institution’s contribution to the Expected Shortfall of the system is its MES, the return it is expected to make when the system as a whole is in its tail. Measured over a year of daily returns on the 5% worst days of the market, the MES of the financial firms before 2007 predicted which of them lost the most in the crisis. Where the CoVaR asks how much the system suffers when a firm is in distress, the MES asks how much a firm suffers when the system is; it is the market component of SRISK (see get_srisk).
The formula is as follows (with the default alpha=0.05):
\[\text{VaR}_{\text{alpha}}(\text{Market}) = \operatorname{Quantile}(\text{Market Returns within the period},\; \alpha)\] \[\text{MES} = \operatorname{MEAN}(\text{Returns}_{t} \mid \text{Market Return}_{t} \leq \text{VaR}_{\text{alpha}}(\text{Market}))\]Where the returns are the daily returns of the Adjusted Close within the period on the days the ticker and the market both have a return, and the quantile interpolates linearly between the two nearest returns. The MES is reported as a return, negative for a loss, like the Value at Risk and the Conditional Value at Risk (the paper reports the loss, -MES). With rolling, the days of the last rolling periods are used together.
For more information about the method, see the following paper:
- Acharya, V.V., Pedersen, L.H., Philippon, T., & Richardson, M. (2017). “Measuring Systemic Risk.” The Review of Financial Studies, 30(1), 2-47.
Also known as: MES, marginal expected shortfall, systemic expected shortfall, tail beta.
Marginal Expected Shortfall (MES) in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_marginal_expected_shortfall as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["JPM", "BAC", "C", "GS"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.risk.get_marginal_expected_shortfall()
Or, after setting up the Finance Toolkit MCP, ask:
What was the marginal expected shortfall of JPMorgan Chase, Bank of America, Citigroup and Goldman Sachs, their average return on the market's worst 5% of days, in each year from 2021 to 2025?
Which returns:
| Date | JPM | BAC | C | GS |
|---|---|---|---|---|
| 2021 | -0.0126 | -0.0134 | -0.0152 | -0.0173 |
| 2022 | -0.0282 | -0.0315 | -0.029 | -0.0284 |
| 2023 | -0.0155 | -0.0205 | -0.0187 | -0.017 |
| 2024 | -0.02 | -0.0196 | -0.0232 | -0.0233 |
| 2025 | -0.029 | -0.0339 | -0.0393 | -0.0394 |
Parameters
get_marginal_expected_shortfall accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
ticker | str | None | The ticker whose MES to calculate. Defaults to None, which uses every ticker except the market. | "AAPL" |
market_ticker | str | None | The ticker that represents the market (the system). Defaults to None, which uses the benchmark. | None, which uses the benchmark |
period | str | The period of each estimate (monthly, quarterly or yearly). Defaults to “yearly”, as in the paper. | "weekly" |
alpha | float | The tail probability of the market returns. Defaults to 0.05, the 5% worst days of the market. | 0.01 |
rolling | int | Use the daily returns of the last rolling periods instead of one period (e.g. period=’monthly’ and rolling=12 for a one-year window at every month end). Defaults to None. | 4 |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
growth | bool | Whether to calculate the growth of the MES over time. Defaults to False. | True |
lag | int | list[int] | The lag to use for the growth calculation. Defaults to 1. | 4 |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |