L-Moment Risk Measure
Calculate the L-moment Convex Risk Measure: one risk figure for the spread, skew and tails of the returns of an investment portfolio or asset, robust to outliers.
Cajas (2023) combines the L-moments of order 2 up to order into one convex risk measure: a weighted sum of the L-scale, minus the L-moment of order 3 (so a negative skew adds risk), plus that of order 4 and so on, with weights that are non-negative, sum to 1 and decrease with the order. The weights are chosen so that the ordered weighted average they imply puts at least as much weight on every worse return, which keeps the measure convex and therefore usable in portfolio optimization. It captures the dispersion, the skew and the tails of the returns in one figure that is as robust to outliers as the L-moments themselves.
The formula is as follows:
\[\text{L-moment Convex Risk Measure} = \Sigma_{k} \phi_{k} \cdot (- 1)^{k} \cdot \lambda_{k} \;\text{for}\; k = 2,\; \ldots,\; \text{order}\] \[\sum \phi_{k} = 1,\; 0 \leq \phi_{k} \leq \text{max\_weight} \;\text{and}\; \phi_{k} \geq \phi_{k+1}\]Where \(\lambda_{k}\) is the L-moment of order k (get_l_moment) and the \(\phi_{k}\) follow from the method: the minimum squared differences method minimizes the squared differences between the neighbouring weights of the ordered weighted average, the minimum sum of squares method the sum of its squared weights and the constant relative risk aversion method sets \(\phi_{k}\) in proportion to \(\Pi_{i = 1 \ldots k - 1}\) (risk_aversion + i - 1) / k!, after which the ordered weights are made non-decreasing. The result is a positive decimal.
Also known as: L-moment CRM, L-moment based convex risk measure.
Example · V, MA, PYPL · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_l_moment_risk_measure:
from financetoolkit import Toolkit
toolkit = Toolkit(
["V", "MA", "PYPL"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.risk.get_l_moment_risk_measure(period="yearly", within_period=True)
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
What was the L-moment risk measure of the daily returns of Visa, Mastercard, PayPal and the S&P 500 in each year from 2021 to 2025?
Which returns:
| Item | V | MA | PYPL | Benchmark |
|---|---|---|---|---|
| 2021 | 0.0044 | 0.0052 | 0.0068 | 0.0024 |
| 2022 | 0.0054 | 0.0058 | 0.0098 | 0.0044 |
| 2023 | 0.0028 | 0.0031 | 0.0067 | 0.0024 |
| 2024 | 0.0031 | 0.0029 | 0.0061 | 0.0024 |
| 2025 | 0.0039 | 0.0040 | 0.0069 | 0.0032 |
5 rows
Parameters
get_l_moment_risk_measure accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency for returns. Options are: “daily”, “weekly”, “monthly”, “quarterly”, “yearly”. Defaults to “daily”. | "weekly" |
order | int | The highest L-moment order, an integer of 2 or higher. Defaults to 4. | 2 |
method | str | How the L-moments are weighted. Options are: “msd” (minimum squared differences), “mss” (minimum sum of squares), “crra” (constant relative risk aversion). Defaults to “msd”. | "msd" |
risk_aversion | float | The risk aversion of the constant relative risk aversion method, between 0 and 1. Defaults to 0.5. | 0.5 |
max_weight | float | The largest weight of one L-moment for “msd” and “mss”, between 0 and 1. Defaults to 0.5. | 0.5 |
within_period | bool | Whether to calculate the L-moment Convex Risk Measure within the specified period or for the entire period. Thus whether to look at the L-moment Convex Risk Measure 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 |
rolling | int | The rolling window size to use for the calculation. If set, the L-moment Convex Risk Measure 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 |
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 L-moment Convex Risk Measure values 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 |
References
- Paper Cajas, D. (2023). “Higher Order Moment Portfolio Optimization with L-Moments.” SSRN 4393155.
- Paper Hosking, J.R.M. (1990). “L-moments: Analysis and Estimation of Distributions using Linear Combinations of Order Statistics.” Journal of the Royal Statistical Society: Series B, 52(1), 105-124.
- Library Referenced against Riskfolio-Lib’s L_Moment_CRM (constant relative risk aversion)
- Library Shares similar logic as Riskfolio-Lib’s owa_l_moment_crm