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, calculated as the absolute value of the (1 - alpha)-th percentile of returns divided by the absolute value of the alpha-th percentile of returns. A Tail Ratio above 1 indicates that best-case gains outsize worst-case losses.
Also known as: gain-to-pain tail ratio.
No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Tail Ratio for you. Just ask in plain English.
Calculate the Tail Ratio in Python
The Tail Ratio is available in the Risk module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_tail_ratio as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(["AMZN", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")
toolkit.risk.get_tail_ratio()
Which returns:
| AMZN | TSLA | Benchmark | |
|---|---|---|---|
| 2021 | 0.8591 | 1.0173 | 1.0688 |
| 2022 | 0.8406 | 1.0049 | 0.9524 |
| 2023 | 1.2609 | 1.1958 | 1.0432 |
| 2024 | 1.1246 | 1.1942 | 0.9049 |
| 2025 | 0.9359 | 1.0702 | 0.93 |
| 2026 | 1.0012 | 0.9592 | 0.8828 |
Parameters
get_tail_ratio accepts the following parameters:
- period (str, optional): The data frequency for returns (daily, weekly, monthly, quarterly, or yearly). Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”.
- alpha (float, optional): The percentile used to define each tail (e.g., 0.05 uses the 5th and 95th percentile). Defaults to 0.05.
- within_period (bool, optional): 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 True.
- rolling (int, optional): 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. - rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
- growth (bool, optional): Whether to calculate the growth of the Tail Ratio values over time. Defaults to False.
- lag (int | list[int], optional): The lag to use for the growth calculation. Defaults to 1.
- standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.
Related Risk Metrics
The Risk module page introduces the module, and the sidebar lists all of its functions.