Probability of Backtest Overfitting (PBO)

Calculate the Probability of Backtest Overfitting (PBO) of picking the ticker with the best Sharpe ratio: how often the ticker that looks best on one half of the history ends up in the bottom half of the tickers on the other half, with the Combinatorially Symmetric Cross-Validation (CSCV) of Bailey, Borwein, López de Prado and Zhu (2017).

The tickers are the candidate strategies, for instance funds to choose from or the variants of a strategy (such as the Portfolio of every weighting). The daily returns in the date range are split into blocks blocks of equal length and for every way to pick half of the blocks as the in-sample history, with the other half out of sample:

  • The ticker with the highest in-sample Sharpe ratio (mean / standard deviation of the daily returns) is selected.
  • \(\omega\) = Rank of its out-of-sample Sharpe ratio among the N tickers / (N + 1)
  • \[\lambda = \ln (\omega / (1 - \omega))\]
  • PBO = Share of the combinations with \(\lambda \leq 0\)

A PBO close to 0 means the ticker that looked best kept doing well out of sample; around 0.5 or above, selecting on the past Sharpe ratio adds nothing and the best backtest is likely overfit. The table also gives the Average Out-of-Sample Rank (the mean \(\omega\), 0.5 for a random choice), the Probability of Loss (the share of combinations in which the selected ticker has a negative out-of-sample Sharpe ratio), the Performance Degradation (the slope of the regression of the selected ticker’s out-of-sample Sharpe ratio on its in-sample Sharpe ratio, negative when a high in-sample Sharpe ratio is followed by a low one) and the number of Combinations, C(blocks, blocks / 2).

Also known as: PBO, CSCV, combinatorially symmetric cross-validation.

Example · AAPL, MSFT, GOOGL, AMZN, 4 more · 2016 to 2025

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

from financetoolkit import Toolkit

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

toolkit.performance.get_probability_of_backtest_overfitting()

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

If I picked the best of Apple, Microsoft, Alphabet, Amazon, Meta, Nvidia, Tesla and Coca-Cola on 2016 to 2025 data, how likely is it that the choice was overfitted?

Which returns:

Item0
Probability of Backtest Overfitting0.2027
Average Out-of-Sample Rank0.7200
Probability of Loss0.0037
Performance Degradation-0.5358
Combinations12,870.0000

5 rows

Parameters

get_probability_of_backtest_overfitting accepts the following parameters.

ParameterTypeDescriptionExample
blocksintThe number of blocks the history is split into, even and at least 2. 16 gives 12,870 combinations, as in the paper. Defaults to 16.16
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