qis.sharpe_difference_test¶
- qis.sharpe_difference_test(returns1, returns2, n_lags=3, af=12.0)[source]¶
Test equal arithmetic Sharpe ratios on paired periodic returns with HAC.
Implements the delta-method framework of Ledoit and Wolf (2008), section 3.1, with a Bartlett/Newey-West long-run covariance estimate, no prewhitening and no finite-sample correction. It is not their studentized bootstrap test. Population moments (ddof=0) define both Sharpe estimates and their gradients. Positive constant rescaling of either return series leaves inference unchanged.
- Parameters:
returns1 (Series) – First numeric return Series, with unique, sortable, nonmissing index labels. Supply simple periodic excess returns to test excess Sharpes; no cash adjustment, fee deduction, resampling or return conversion is performed internally.
returns2 (Series) – Second return Series on the same sampling grid and return basis. Index intersection is sorted and pairs containing NaN are dropped. Lags count retained observations, so the caller must resolve material calendar gaps first.
n_lags (int | None) – Bartlett truncation, an integer from zero through T-1; defaults to 3, matching QIS’s regression HAC helpers. Explicit None selects floor(4*(T/100)**(2/9)); zero allows nonnormality but ignores serial dependence.
af (float) – Positive finite periods per year, used only for reporting (default 12 for monthly). Both the difference and its standard error scale by sqrt(af); p-values do not.
- Returns:
Annualised Sharpes, their difference and standard error, normal-reference statistic, two-sided p-value, sample size and selected lag count. Identical or positively proportional returns have zero difference/standard error and, by convention, z=0, p=1.
- Raises:
ValueError – If inputs/settings are invalid, fewer than 24 complete pairs remain, a return variance is numerically degenerate, or inference is undefined.
- Return type:
Notes
Covariance uses QIS’s estimate_hac_mean on the paired influence series. Its T/(T-1) correction is removed to retain this test’s uncorrected delta-method convention. Asymptotic validity requires stationary paired returns, sufficient finite moments and weak dependence. A significant result does not correct for strategy selection. The field t_stat is retained for familiarity; it does not use Student’s t distribution.