esvhd/pypbo ? reverse-engineered prompt

Reverse engineered prompt

Build me a small Python library for measuring backtest overfitting in trading strategies.

I want to be able to pass in a table of returns and get back things like probability of backtest overfitting, probability of out of sample performance falling below a threshold, performance degradation, stochastic dominance, probabilistic Sharpe ratio stats, minimum track record length, minimum backtest length, and deflated Sharpe ratio stats.

Please make it easy to use from code with a simple function call, and include plotting support so I can quickly see the results. If there are any tricky finance formulas or edge cases, please implement them carefully and add tests for the main calculations.

Use current Python best practices, and if you need to check the exact math or a reference implementation, look up the current docs or papers online. Also include a small example showing how to call it on a returns dataframe with a custom metric function.