Pain Ratio
Calculate the Pain Ratio of an investment portfolio or asset’s returns.
The Pain Ratio divides the excess return (return minus the risk-free rate) of an investment portfolio or asset by its Pain Index, the mean depth of its drawdowns. Where the Ulcer Performance Index squares the drawdowns, which makes the deep ones dominate, the Pain Index weighs every observation under water by its depth alone.
The formula is as follows:
\[\text{Pain Ratio} = \frac{\text{Period Return} - \text{Risk-Free Rate}}{\text{Pain Index}}\] \[\text{Pain Index} = \frac{\sum(\left|\text{Drawdown}_{t}\right|)}{N}\] \[\text{Drawdown}_{t} = \frac{\text{Wealth}_{t}}{\text{Peak}_{t}} - 1,\;\; \text{with Peak\_t the highest wealth since the first return}\]With within_period=True (the default) the observations are the daily returns within each period: N is the number of days in the period, and the wealth and its peak restart from 1 before the first return of every period, so a loss on its first day is a drawdown as well. With within_period=False the observations are the period returns (such as the yearly returns) of the full history: N is the number of those periods, and every period’s excess return is divided by that one Pain Index, as the Calmar, Sterling and Burke ratios do. Observations at a new high count as a drawdown of 0. The risk-free rate is compounded over the days of the period, so a partial period (such as the current year) earns the rate of the days it covers. Bacon (2013) divides the annualized return minus the risk-free rate; for period=”yearly” that is the same for every full year, and for other periods the ratio uses the period’s own (not annualized) excess return, as the Ulcer Performance Index and the Burke Ratio do.
For more information, see the following source:
- Bacon, C.R. (2013). “Practical Risk-Adjusted Performance Measurement.” John Wiley & Sons, chapter 5 (the Pain Index and Pain Ratio of Zephyr Associates).
Pain Ratio in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_pain_ratio as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["HD", "LOW", "TGT"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.performance.get_pain_ratio()
Or, after setting up the Finance Toolkit MCP, ask:
What was the pain ratio of Home Depot, Lowe's and Target in each year from 2022 to 2025?
Which returns:
| Date | HD | LOW | TGT |
|---|---|---|---|
| 2022 | -1.0217 | -1.1848 | -1.468 |
| 2023 | 1.0889 | 1.3693 | -0.2573 |
| 2024 | 1.7048 | 1.3511 | -0.5582 |
| 2025 | -1.3355 | -0.4223 | -1.0867 |
Parameters
get_pain_ratio accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The period to use for the calculation. Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”. | "weekly" |
within_period | bool | Whether to calculate the Pain Index from the daily drawdowns within each period (if period = ‘yearly’, a Pain Index per year) or from the drawdowns of the period returns over the full history (one Pain Index from the yearly returns of all years). Defaults to True. | True |
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 ratios. 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 |