Outperformance Probability

Calculate the probability of outperformance of an investment portfolio or asset: the share of all windows of a given number of periods (for example every 12 consecutive months) in which it returned more than the benchmark. Looking at windows of different lengths shows whether an asset that often lags over a month still tends to come out ahead over one or three years.

The formula is as follows:

\[\text{Window Return} = \operatorname{PRODUCT}(1 + \text{Return over the window}) - 1\] \[\text{Probability of Outperformance} = \text{Number of Windows with Window Return} > \frac{\text{Benchmark Window Return}}{\text{Number of Windows in}} \;\text{which they differ}\]

The windows end at every period from the first full window onwards, so consecutive windows overlap and a longer window has fewer of them. Measured on its own the window return is compared with 0 instead of the benchmark’s, the share of windows with a gain: for 12 monthly returns ffn’s “Win 12m %”.

The measure is defined in PerformanceAnalytics (Peterson and Carl) as table.ProbOutPerformance; the Toolkit applies it to each ticker against its benchmark.

Also known as: rolling win rate, hit rate over rolling windows.

Example · AAPL, MSFT, KO · 2016 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_outperformance_probability:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT", "KO"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2016-01-01",
    end_date="2025-12-31",
)

toolkit.performance.get_outperformance_probability()

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

How likely were Apple, Microsoft and Coca-Cola to beat the S&P 500 over holding periods of 1 to 36 months, based on 2016 to 2025?

Which returns:

Parameters

get_outperformance_probability accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe period of the returns the windows are made of. Options are: “daily”, “weekly”, “monthly”, “quarterly”, “yearly”. Defaults to “monthly”."weekly"
windowslist[int] | NoneThe window lengths in periods. Defaults to None, which uses 1, 3, 6, 9, 12, 18 and 36 (PerformanceAnalytics’ defaults).[21, 63, 126, 252]
relativeboolWhether to compare with the benchmark (True) or with a return of 0 (False). Defaults to True.True
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
show_columnsstr | list[str] | NoneThe 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

References

Share