Gain-to-Pain Ratio
Calculate the Gain-to-Pain Ratio of an investment portfolio or asset’s returns.
The Gain-to-Pain Ratio, popularized by Jack Schwager, divides the sum of all returns by the sum of the absolute value of all losses, summarizing the entire return history into a single measure of return earned per unit of pain endured.
The formula is as follows:
\[\text{Gain-to-Pain Ratio} = \operatorname{SUM}(\text{Returns}) / \operatorname{SUM}(| \text{Losses} |)\]No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Gain-to-Pain Ratio for you. Just ask in plain English.
Calculate the Gain-to-Pain Ratio in Python
The Gain-to-Pain Ratio is available in the Performance module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_gain_to_pain_ratio as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(["AAPL", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")
toolkit.performance.get_gain_to_pain_ratio()
Which returns:
| AAPL | TSLA | |
|---|---|---|
| 2021 | 0.2354 | 0.1945 |
| 2022 | -0.108 | -0.1871 |
| 2023 | 0.4034 | 0.3043 |
| 2024 | 0.2462 | 0.2098 |
| 2025 | 0.0873 | 0.0871 |
| 2026 | 0.2062 | -0.0642 |
Parameters
get_gain_to_pain_ratio accepts the following parameters:
- period (str, optional): The period to use for the calculation. Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”.
- within_period (bool, optional): Whether to calculate the Gain-to-Pain Ratio within the specified period or for the entire period. Thus whether to look at the Gain-to-Pain Ratio within a specific year (if period = ‘yearly’) or look at the entirety of all years. Defaults to True.
- rounding (int, optional): The number of decimals to round the results to. Defaults to 4.
- growth (bool, optional): Whether to calculate the growth of the ratios. Defaults to False.
- lag (int | str, 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 Performance Metrics
The Performance module page introduces the module, and the sidebar lists all of its functions.