Tail Ratio
Calculate the Tail Ratio of an investment portfolio or asset’s returns.
The Tail Ratio compares the size of the right (gain) tail to the left (loss) tail of the return distribution. A Tail Ratio above 1 indicates that best-case gains outsize worst-case losses.
The formula is as follows (with the default alpha=0.05):
\[\text{Tail Ratio} = | \operatorname{Quantile}(\text{Returns},\; 1 - \alpha) | / | \operatorname{Quantile}(\text{Returns},\; \alpha) |\]The quantiles interpolate linearly, and a left-tail quantile of 0 gives NaN.
Also known as: gain-to-pain tail ratio.
Tail Ratio in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_tail_ratio as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["QQQ", "TLT", "GLD"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.risk.get_tail_ratio(period="yearly", within_period=True)
Or, after setting up the Finance Toolkit MCP, ask:
How did the right tail of daily returns compare with the left tail for QQQ, TLT, GLD and the S&P 500 in each year from 2021 to 2025?
Which returns:
| QQQ | TLT | GLD | Benchmark | |
|---|---|---|---|---|
| 2021 | 0.9646 | 1.0836 | 0.7734 | 1.1304 |
| 2022 | 0.9109 | 0.8904 | 1.0385 | 0.9524 |
| 2023 | 1.2227 | 1.1695 | 1.1281 | 1.0466 |
| 2024 | 0.9029 | 0.8128 | 1.072 | 0.9091 |
| 2025 | 0.8622 | 1.104 | 1.2495 | 0.93 |
Parameters
get_tail_ratio accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency for returns (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”. | "weekly" |
alpha | float | The percentile used to define each tail (e.g., 0.05 uses the 5th and 95th percentile). Defaults to 0.05. | 0.01 |
within_period | bool | Whether to calculate the Tail Ratio within the specified period or for the entire period. Thus whether to look at the Tail Ratio 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 Ratio is calculated over a rolling window of this many periods across the full return history instead of per period. Defaults to None. | 20 |
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 Ratio 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 |