Deflating the Sharpe after a grid search (the winner is a max over N) #866
ipezygj
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
vectorbt makes it trivial to test thousands of parameter/asset combinations at once — which is exactly why the top result of a grid needs one extra step before you trust it.
When you take the best Sharpe out of a grid, that number is a maximum over N trials, not a single-test Sharpe. The expected best of N random strategies is already well above zero, so the grid's winner can look great and still sit inside the noise band of the search. That's what the Deflated Sharpe Ratio (Bailey & López de Prado) corrects for — and the nice thing about a grid is you don't have to assume how noisy the search was, you can measure it from the spread of Sharpes the grid already produced.
A few lines on top of a vectorbt grid — MIT tool,
pip install numguard, no heavy deps:If the DSR is near zero while the raw Sharpe looked strong, the grid found a lucky maximum, not an edge. It turns a "which combo won?" plot into "did the winner clear its own search bar?".
There's also a fuller battery on a returns series (CSCV Probability of Backtest Overfitting across the candidates matrix, a same-bar look-ahead scan, autocorrelation-inflated Sharpe) if you want it. Repo: https://github.com/ipezygj/numguard — feedback welcome, especially on the vectorbt wiring.
All reactions