# strategy-statistical-validation

> Test whether a backtested edge is real: PSR, deflated Sharpe, PBO/CSCV, walk-forward, multiple-testing and bootstrap CIs.

strategy-statistical-validation is a paid AI agent skill on Agensi by BanditXBT. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $29 (one-time purchase)
- Creator: [BanditXBT](https://www.agensi.io/creators/banditxbt)
- Version: 1.0
- Last updated: 2026-11-21
- Security: scan passed (2026-11-21); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/strategy-statistical-validation
- Tags: trading-investing, research-analysis, testing-debugging

## About this skill

Question: given how many things were tried, how much data exists, and how non-normal the returns are, what is the probability the true Sharpe exceeds a hurdle? Educational analysis, not investment advice; state assumptions and data sources.

1. **Count trials N honestly.** Every parameter cell, feature set, universe, rebalance frequency, and discarded idea counts. When N is large and trials are correlated, estimate an effective N (e.g., clustering trial returns, or eigenvalues of the trial correlation matrix); this is a judgment call, so report results across a range of N.
2. **Per-period Sharpe** `SR = mean/std` at native frequency, T observations. Annualize only for reporting: `sqrt(periods_per_year)` is valid under iid; for autocorrelated returns use Lo (2002) adjustment.
3. **PSR (Bailey and Lopez de Prado 2012).** `PSR(SR*) = Phi( (SR - SR*) sqrt(T-1) / sqrt(1 - g3*SR + (g4-1)/4 * SR^2) )`; g3 skewness, g4 raw kurtosis (normal = 3), SR and SR* non-annualized.
4. **DSR (Bailey and Lopez de Prado 2014).** Replace SR* by the expected maximum Sharpe of N unskilled trials: `SR0 = sqrt(V) * ((1-gamma)*Phi^-1(1-1/N) + gamma*Phi^-1(1-1/(N*e)))`, V = variance of per-period SRs across trials, gamma = 0.5772 (Euler-Mascheroni). `DSR = PSR(SR0)`. A common convention is DSR >= 0.95 (a conventional confidence level, not a theorem).
5. **MinTRL.** `1 + (1 - g3*SR + (g4-1)/4*SR^2) * (z/(SR - SR*))^2`, z = Phi^-1(confidence), e.g. 1.645 for 95% one-sided. Compare with available T.
6. **PBO via CSCV (Bailey, Borwein, Lopez de Prado, Zhu).** Matrix M (T x N trials). Split rows into S even blocks (S=16 gives 12,870 combinations; S=8-16 typical). For each combination of S/2 blocks as in-sample, pick the best in-sample trial, take its out-of-sample relative rank omega = rank/(N+1), logit `lambda = ln(omega/(1-omega))`. `PBO` = share of combinations with lambda <= 0 (best IS trial lands at or below the OOS median). Also report performance degradation (IS vs OOS regression) and probability of OOS loss.
7. **Walk-forward / purged CV.** Refit every hyperparameter inside each training window; purge and embargo overlapping labels; report the stitched OOS curve only. Combinatorial purged CV yields a distribution of OOS paths. Keep a final untouched holdout.
8. **Multiple-testing correction.** Family-wise: Bonferroni/Holm; bootstrap White's Reality Check (2000), Hansen's SPA (2005), Romano-Wolf stepdown (2005). FDR: Benjamini-Hochberg (Benjamini-Yekutieli under dependence). Harvey, Liu, Zhu (*RFS* 2016) estimate that a newly discovered factor needs a t-ratio above about 3.0.
9. **Bootstrap CI.** Stationary bootstrap (Politis-Romano 1994) with block length from Politis-White (corrected by Patton-Politis-White 2009); report CIs for Sharpe, max drawdown, Calmar.

def psr(r, sr_star=0.0):
    r = np.asarray(r); T = len(r); sr = r.mean()/r.std(ddof=1)
    g3, g4 = skew(r), kurtosis(r, fisher=False)
    return norm.cdf((sr-sr_star)*np.sqrt(T-1)/np.sqrt(1-g3*sr+(g4-1)/4*sr**2))

def sr0(var_sr, N, g=0.5772156649):
    return np.sqrt(var_sr)*((1-g)*norm.ppf(1-1/N)+g*norm.ppf(1-1/(N*np.e)))

## Requires

- Python 3
- numpy
- scipy
- arch

## Known limitations

Educational analysis, not investment advice. DSR depends on an honestly counted number of trials; confirm arch method names for your installed version.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the strategy-statistical-validation skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What does strategy-statistical-validation do?

Test whether a backtested edge is real: PSR, deflated Sharpe, PBO/CSCV, walk-forward, multiple-testing and bootstrap CIs.

### Which AI agents support strategy-statistical-validation?

This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

### How do I use strategy-statistical-validation?

Connect your AI agent to Agensi through MCP, then ask it to use strategy-statistical-validation on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
