Higher Moment Coherent Risk (HMCR)

Calculate the Higher Moment Coherent Risk (HMCR) of an investment portfolio or asset’s returns: a tail loss like the CVaR that weighs the deepest losses more, by default the Coherent Second Moment (CSM).

The Conditional Value at Risk averages the losses beyond a threshold, so a loss twice as deep counts twice. The Higher Moment Coherent Risk measures those losses with a higher moment instead: of order 2 it takes the root mean square of the losses beyond the threshold, so a loss twice as deep counts four times inside the square, and the measure reacts more to fat tails than the CVaR does. It stays a coherent risk measure (Krokhmal 2007): it scales with the position, shifts with cash, rewards diversification and rises with the losses, which makes it a portfolio objective (the minimum CSM portfolio) that the variance and the VaR are not.

The formula is as follows (with the default order of 2 and an alpha of 0.05):

\[\text{Loss} = - \text{Return}\] \[\text{HMCR} = \min \;\text{over}\; \zeta \;\text{of}\; \zeta + \frac{1}{\alpha} \cdot (\operatorname{Mean}(\max(\text{Loss} - \zeta,\; 0)^{\text{order}}))^{\frac{1}{\text{order}}}\]

Where \(\zeta\) is a threshold (the minimum is found by bisection on the derivative, which the convexity of the objective makes increasing) and the mean runs over the n returns. With an order of 1 it is the CVaR in the minimization form of Rockafellar and Uryasev (2002). A higher order weighs the deepest losses more, so the HMCR rises with the order towards the worst return. The result is a return, negative for a loss, as the VaR, CVaR and EVaR of the Toolkit are.

Also known as: HMCR, Coherent Second Moment, CSM, higher moment risk, second moment coherent risk.

Example · GLD, SLV, USO · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_higher_moment_coherent_risk:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["GLD", "SLV", "USO"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.risk.get_higher_moment_coherent_risk()

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

What was the 95% higher moment coherent risk (the coherent second moment) of the daily returns of the SPDR Gold Shares (GLD), iShares Silver Trust (SLV), United States Oil Fund (USO) and the S&P 500 from 2021 to 2025?

Which returns:

Parameters

get_higher_moment_coherent_risk accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe data frequency for returns. Options are: “daily”, “weekly”, “monthly”, “quarterly”, “yearly”. Defaults to “daily”."weekly"
orderfloatThe order p of the moment, at least 1. Defaults to 2.2
alphafloatThe tail probability (e.g., 0.05 for the 95% confidence level). Defaults to 0.05.0.01
within_periodboolWhether to calculate the HMCR within the specified period or for the entire period. Thus whether to look at the HMCR within a specific year (if period = ‘yearly’) or look at the entirety of all years. Defaults to False. Note that this requires intraday data when period = ‘daily’, since a single day only nests observations when intraday data was fetched.True
rollingintThe rolling window size to use for the calculation. If set, the HMCR is calculated over a rolling window of this many periods across the full return history instead of per period. At least 2. Defaults to None.4
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
growthboolWhether to calculate the growth of the HMCR values over time. Defaults to False.True
lagint | list[int]The lag to use for the growth calculation. Defaults to 1.4
standardizeboolWhether 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_columnsstr | list[str] | NoneThe 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

References

  • Paper Krokhmal, P.A. (2007). “Higher Moment Coherent Risk Measures.” Quantitative Finance, 7(4), 373-387.
  • Paper Rockafellar, R.T. and Uryasev, S. (2002). “Conditional Value-at-Risk for General Loss Distributions.” Journal of Banking & Finance, 26(7), 1443-1471.
  • Library Shares similar logic as PortfolioAnalytics (R)’s extract_risk
Share