mcpField
S
sharpe-ratio-non-iid-corrections

sharpe-ratio-non-iid-corrections

github.com/terrylicaData & databases171 installsUpdated 1d ago
Repository

About sharpe-ratio-non-iid-corrections

A reference skill for evaluating a single strategy’s Sharpe ratio when returns are non-Normal and serially correlated. It implements variance correction and related single-test statistics, without trial-count corrections.

Key features

  1. 01Non-IID Sharpe variance correction
  2. 02Probabilistic Sharpe Ratio (PSR)
  3. 03Minimum track record length (MinTRL)
  4. 04Critical Sharpe and power calculations
  5. 05Numba JIT reference implementation

Use cases

  1. 01Assess a strategy with skewed, heavy-tailed returns
  2. 02Account for lag-1 autocorrelation in inference
  3. 03Estimate track record length against a benchmark

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/terrylica/cc-skills --skill sharpe-ratio-non-iid-corrections

After installing, type/sharpe-ratio-non-iid-correctionsin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
how-to-use-the-sharpe-ratio-2026.md
sharpe_numba.py
sharpe-paper-tracker.md

Details

From the project README

Sharpe Ratio Non-IID Corrections

Sharpe ratio inference for a single strategy whose returns are non-Normal and serially correlated. Reference implementation of the generalized sampling variance in López de Prado, Lipton & Zoonekynd (2026), and of the single-test statistics that use it.

Self-Evolving Skill: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.

Out of scope — do not re-add (operator rule, 2026-10-15)

Never compute, report, rank by or cite the Deflated Sharpe Ratio or any other trial-count correction: FWER and FDR procedures (Holm, Bonferroni/Šidák, Benjamini-Yekutieli, the paper's pFDR/oFDR/SFDR), e-LOND and other online multiple testing, expected-maximum-Sharpe deflation, effective-number-of-trials estimates, and the minimum backtest length (MinBTL), which is a function of the number of trials. MinTRL is a different quantity (one rule's own track record) and stays. They were removed from this skill on purpose. Instead:

  • Judge parsimony on the model itself (how many free parameters, how much was tuned), not by deflating a Sharpe for the number of trials.
  • Guard selection with registration before runs and with unused data: fix the hypothesis, rule and evaluation window before running, and confirm on data no run has touched.
  • Report each rule's own statistics: its Sharpe, ρ-corrected σ[SR̂], PSR, MinTRL and power.

PSR, MinTRL, the ρ-corrected variance and power are single-test statistics and stay. PBO/CSCV describes a selection procedure and is not covered by the rule.

Quick Start

# Run the 9 validation tests (paper Exhibit 1 numerical examples)
uv run --no-project --with numpy --with numba \
  python plugins/quant-research/skills/sharpe-ratio-non-iid-corrections/references/sharpe_numba.py

Paper Metadata

FieldValue
TitleHow to Use the Sharpe Ratio
AuthorsMarcos López de Prado, Alexander Lipton, Vincent Zoonekynd
SeriesADIA Lab Research Paper Series, No. 19
DateMarch 7, 2026
SSRN5520741
Replicationhttps://github.com/zoonek/2025-sharpe-ratio
Source PDFlopez-de-prado-sharpe-2026.pdf

The PDF is kept because the variance derivation (Section 2, Appendix A.1–A.2) and the PSR/MinTRL/power equations this skill implements are cited by equation number from it. Only those sections are used; the transcription omits the rest.

References

TopicReference File
Paper transcription (implemented excerpt)how-to-use-the-sharpe-ratio-2026.md
Equation → Implementation Trackersharpe-paper-tracker.md
Numba JIT Implementationsharpe_numba.py
Source PDFlopez-de-prado-sharpe-2026.pdf
Paper Figuresmedia/ (Exhibit 2, variance vs autocorrelation, pp. 12-13)

Preflight: what to compute

Inputs are all objective, computed from the return series under evaluation:

ParameterMeaningSource
SR̂Observed (non-annualized) Sharpe ratioReturn series
TNumber of return observationsReturn series
γ₃, γ₄Skewness, Pearson kurtosis (γ₄=3 is Gaussian)Return series
ρLag-1 autocorrelationReturn series
SR₀Benchmark Sharpe under the null (often 0)Fixed before the run
SR₁, αAlternative Sharpe and test size, for powerFixed before the run

Fix SR₀, SR₁ and α in the registration, before looking at results. Report SR̂, σ[SR̂], PSR, MinTRL against T, and power together.

Key Formulas

All equations use the paper's non-IID variance (Eq 2-3) with Pearson kurtosis convention (γ₄=3 for Gaussian).

EqNameFormulaFunction
2-3SR VarianceV[SR̂] = (1/T)·(a − b·γ₃·SR + c·(γ₄−1)/4·SR²)sr_variance()
9PSRΦ((SR̂ − SR₀) / σ[SR₀])psr()
11MinTRL(a − b·γ₃·SR₀ + c·(γ₄−1)/4·SR₀²) · (z_{1−α}/(SR̂−SR₀))²min_trl()
8, 14Critical SRSR₀ + σ[SR₀]·z_{1−α}critical_sr()
13-15Power1 − Φ((SR_c − SR₁) / σ[SR₁])power()
17β (Type II)Φ((z_{1−α}·√(a(ρ)) − SR₁·√T) / √(a − b·γ₃·SR₁ + c·(γ₄−1)/4·SR₁²))power() → 1 - power

Where a = (1+ρ)/(1−ρ), b = (1+ρ+ρ²)/(1−ρ²), c = (1+ρ²)/(1−ρ²) are AR(1) variance coefficients (ar1_variance_coeffs()).

Numerical Example (Paper Exhibit 1)

Hedge fund: T=24 months, γ₃=−2.448, γ₄=10.164 (Pearson), SR=0.036/0.079≈0.456, ρ=0.2.

QuantityEquationValueNotes
σ[SR̂] (non-Gaussian)Eq 30.379vs 0.214 Gaussian — 77% wider
PSR (SR₀=0)Eq 90.966Still significant despite wider CI
PSR (SR₀=0.1)Eq 9+50.900Harder benchmark reduces confidence
MinTRL (SR₀=0)Eq 1119.543 monthsT=24 > 19.5 → sufficient
MinTRL (SR₀=0.1)Eq 1139.369 monthsMore than doubles for SR₀ closer to SR̂
β (power, SR₁=0.5)Eq 170.411vs 0.224 IID Normal — 84% higher
Power (1−β)Eq 150.589Low for 24-month track record

Implementation Architecture

4-tier dependency hierarchy (Numba JIT, Rust-ready):

Tier 0: erfinv, norm_cdf, norm_ppf
Tier 1: sr_variance (Eqs 3/58), ar1_variance_coeffs
Tier 2: psr (Eq 9), min_trl (Eq 11), critical_sr (Eq 8)
Tier 3: power (Eqs 12-17)

Related Skills

SkillRelationship
opendeviation-eval-metricsConsumes PSR and MinTRL for range bar evaluation (ρ=0 quick-ref)
adaptive-wfo-epochReports PSR per walk-forward fold

Post-Execution Reflection

After this skill completes, check before closing:

  1. Did the command succeed? — If not, fix the instruction or error table that caused the failure.
  2. Did parameters or output change? — If the underlying tool's interface drifted, update Usage examples and Parameters table to match.
  3. Was a workaround needed? — If you had to improvise (different flags, extra steps), update this SKILL.md so the next invocation doesn't need the same workaround.

Only update if the issue is real and reproducible — not speculative.

Comments

Markdown supported