Tail Gini
Calculate the Tail Gini: the loss in the worst tail of the returns of an investment portfolio or asset, weighing the worst returns within that tail most.
The Tail Gini of Furman, Wang and Zitikis (2017) measures the variability within the loss tail, the alpha share of the worst returns. Cajas (2021) writes it as a weighted average of the Conditional Value at Risk at tail probabilities from 0.0001 up to alpha, which puts more weight on the worst returns within the tail than the Conditional Value at Risk at alpha, which weighs every return in the tail equally. It is therefore always at or below the Conditional Value at Risk and above the Worst Realization.
The formula is as follows (with the default alpha of 0.05 and 100 points):
\[\text{Tail Gini} = \Sigma_{j} c_{j} \cdot \operatorname{CVaR}(\alpha_{j})\] \[c_{1} = \frac{\alpha_{2} \cdot \alpha_{1}}{\alpha^{2}},\;\; c_{j} = \frac{(\alpha_{j+1} - \alpha_{j-1}) \cdot \alpha_{j}}{\alpha^{2}}\;\;\text{and}\;\; c_{m} = \frac{\alpha_{m} - \alpha_{m-1}}{\alpha}\]Where \(\alpha_{1} < \ldots < \alpha_{m} = \alpha\) are m = points evenly spaced tail probabilities from 0.0001 to alpha and \(\text{CVaR} (\alpha_{j})\) is the average of the \(\alpha_{j}\) share of the lowest returns, the return at the boundary counting with its fraction (the ordered weighted average of Cajas 2021). The result is a return, negative for a loss, as the Conditional Value at Risk of the Toolkit is.
Also known as: TG, Gini shortfall, tail Gini risk.
Example · TSLA, F, GM · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_tail_gini:
from financetoolkit import Toolkit
toolkit = Toolkit(
["TSLA", "F", "GM"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.risk.get_tail_gini(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 tail Gini of the worst 5% of daily returns of Tesla, Ford, General Motors and the S&P 500 in each year from 2021 to 2025?
Which returns:
| Item | TSLA | F | GM | Benchmark |
|---|---|---|---|---|
| 2021 | -0.0785 | -0.0558 | -0.0560 | -0.0207 |
| 2022 | -0.1000 | -0.0823 | -0.0642 | -0.0365 |
| 2023 | -0.0832 | -0.0642 | -0.0462 | -0.0168 |
| 2024 | -0.0902 | -0.0719 | -0.0542 | -0.0218 |
| 2025 | -0.0990 | -0.0526 | -0.0582 | -0.0348 |
5 rows
Parameters
get_tail_gini 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" |
alpha | float | The tail probability, between 0.0001 and 1. Defaults to 0.05. | 0.01 |
points | int | The number of tail probabilities the Conditional Value at Risk is averaged over. Defaults to 100. | 100 |
within_period | bool | Whether to calculate the Tail Gini within the specified period or for the entire period. Thus whether to look at the Tail Gini 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 Tail Gini 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 Tail Gini 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 Furman, E., Wang, R. and Zitikis, R. (2017). “Gini-type Measures of Risk and Variability: Gini Shortfall, Capital Allocations, and Heavy-tailed Risks.” Journal of Banking & Finance, 83, 70-84.
- Paper Cajas, D. (2021). “OWA Portfolio Optimization: A Disciplined Convex Programming Framework.” SSRN Electronic Journal.
- Library Referenced against Riskfolio-Lib’s TG
- Library Shares similar logic as Riskfolio-Lib’s owa_tg