Pain Index
The Pain Index, developed by Zephyr Associates and described by Bacon (2013), measures the downside risk of an investment portfolio or asset as the average depth of its drawdowns over every day of a period, the days at a new high counting as a drawdown of 0.
Like the Ulcer Index it grows with both the depth and the duration of the drawdowns, so an asset that falls 10% and stays there for months scores worse than one that drops 10% and recovers within a week. Where the Ulcer Index takes the root mean square of the drawdowns, which makes the deepest ones dominate, the Pain Index takes their plain average: the area under water divided by the number of days. It is the risk measure behind the Pain Ratio (excess return divided by the Pain Index, see toolkit.performance.get_pain_ratio).
The formula is as follows:
\[\operatorname{Wealth}(t) = \prod(1 + \operatorname{Return}(s)) \;\text{for}\; s \leq t\] \[\operatorname{Drawdown}(t) = \frac{\operatorname{Wealth}(t)}{\max(1,\; \max(\operatorname{Wealth}(s) \;\text{for}\; s \leq t))} - 1\] \[\text{Pain Index} = \frac{\sum\left|\operatorname{Drawdown}(t)\right|}{n}\]Where Wealth(t) compounds the daily returns within each period from a starting value of 1, so a loss on the first day of the period is a drawdown as well, the drawdowns are measured from the highest wealth since the start of the period and n is the number of daily returns in the period. The result is a positive decimal (0.05 is an average drawdown of 5%). Each ticker is measured over its own trading days, and the days before its first or after its last return (a later listing, a delisting) are no observations of it.
For more information, see the following sources:
- Bacon, C.R. (2013). “Practical Risk-Adjusted Performance Measurement.” John Wiley & Sons, chapter 5 (the Pain Index of Zephyr Associates).
- PerformanceAnalytics (R),
PainIndex.
Also known as: average drawdown, mean drawdown.
Pain Index in Python
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_pain_index as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["BA", "AIR.PA"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.risk.get_pain_index()
Which returns:
| Item | BA | AIR.PA | Benchmark |
|---|---|---|---|
| 2021 | 0.1321 | 0.0404 | 0.009 |
| 2022 | 0.2629 | 0.1135 | 0.139 |
| 2023 | 0.0702 | 0.031 | 0.0223 |
| 2024 | 0.3182 | 0.1191 | 0.0113 |
| 2025 | 0.0715 | 0.0447 | 0.0278 |
Parameters
get_pain_index accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency for returns (daily, weekly, monthly, quarterly, or yearly). Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”. | "weekly" |
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 Pain Index 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 |