Ledoit-Wolf Test
The Ledoit-Wolf Test of Ledoit and Wolf (2008) replaces that standard error with a heteroskedasticity and autocorrelation consistent (HAC) one, so that it stays valid for fat-tailed and serially correlated returns. It works from four moments of the two excess return series, their means and the means of their squares, and gets the standard error of the difference by the delta method from the long-run covariance of those moments.
The formula for the Ledoit-Wolf Test starts from the difference Delta of the two Sharpe ratios, written in the means \(\mu_{a}\) and \(\mu_{b}\) of the excess returns of the asset and the benchmark and the means \(\gamma_{a}\) and \(\gamma_{b}\) of their squares:
\[\Delta = \frac{\mu_{a}}{\sqrt{\gamma_{a} - \mu_{a}^{2}}} - \frac{\mu_{b}}{\sqrt{\gamma_{b} - \mu_{b}^{2}}}\]The delta method needs the gradient G of Delta in those four moments, \(G = (\gamma_{a} / c_{a} , - \gamma_{b} / c_{b} , - \mu_{a} / (2 \cdot c_{a}) , \mu_{b} / (2 \cdot c_{b}))\), with \(c_{a}\) and \(c_{b}\) the cubed standard deviations:
\[c_{a} = \left(\gamma_{a} - \mu_{a}^{2}\right)^{3/2}\] \[c_{b} = \left(\gamma_{b} - \mu_{b}^{2}\right)^{3/2}\]The moment conditions of date t, \(y_{t} = (r_{a} (t) - \mu_{a} , r_{b} (t) - \mu_{b} , r_{a} (t)^{2} - \gamma_{a} , r_{b} (t)^{2} - \gamma_{b})\), with \(r_{a}\) and \(r_{b}\) the excess returns, give the autocovariances \(\text{Gamma}_{j}\) at lag j over the n dates, and their weighted sum over L lags the long-run covariance Psi (the Bartlett kernel of Newey and West, 1987):
\[\Gamma_{j} = \frac{\sum_{t=j + 1}^{n} y_{t} \cdot y'_{t-j}}{n}\] \[\Psi = \frac{n}{n - 4} \cdot \left(\Gamma_{0} + \sum_{j=1}^{L} \left(1 - \frac{j}{L + 1}\right) \cdot (\Gamma_{j} + \Gamma'_{j})\right)\]The test statistic divides the difference by its standard error, and the p-value follows from the standard normal distribution function Phi:
\[z = \frac{\Delta}{\sqrt{\frac{G' \cdot \Psi \cdot G}{n}}}\] \[\text{P Value} = 2 \cdot \left(1 - \Phi\left(\left\lvert z\right\rvert\right)\right)\]For independent, normal returns both tests estimate the same standard error as the sample grows; with fat tails or serial correlation only the Ledoit-Wolf Test keeps the chance of a false rejection at the chosen level.
Two Sharpe ratios measured over a year of daily returns are both estimates, and because two assets in the same market move together, their estimation errors are correlated. Comparing the two separate standard errors ignores that correlation, so a test of whether two Sharpe ratios differ needs the standard error of their difference, measured on the same dates. The null hypothesis is that the two true Sharpe ratios are equal; a low p-value rejects it, and the sign of the Sharpe Difference says which of the two is higher. With a year of daily returns the standard error of a Sharpe ratio is large, so a difference has to be large to be significant.
Also known as: robust Sharpe ratio test, HAC Sharpe ratio test, Sharpe ratio significance test.
In the Finance Toolkit this is get_sharpe_ratio_difference_test with method="ledoit_wolf", the same function as Sharpe Ratio Difference Test.
Example · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_sharpe_ratio_difference_test:
from financetoolkit import Toolkit
toolkit = Toolkit(
"MSFT",
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.performance.get_sharpe_ratio_difference_test(method="ledoit_wolf")["MSFT"]
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The period to use for the calculation. Options are: “daily”, “weekly”, “monthly”, “quarterly”, “yearly”. Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”. | "weekly" |
method | str | The test. Options are: “memmel” (Jobson-Korkie-Memmel Test, for independent normal returns), “ledoit_wolf” (Ledoit-Wolf Test, with a HAC standard error). Defaults to “memmel”. | "memmel" |
lags | int | The number of lags L in the Newey-West covariance, only used when method=”ledoit_wolf”. Defaults to None, which uses the Newey and West (1994) rule floor(4 * (n / 100)^(2/9)), 4 for a year of daily returns. | 2 |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
Which returns:
| Item | Sharpe Difference | Standard Error | Z-Statistic | P-Value |
|---|---|---|---|---|
| 2021 | 0.0088 | 0.0509 | 0.1722 | 0.8633 |
| 2022 | -0.0007 | 0.0326 | -0.0218 | 0.9826 |
| 2023 | 0.0160 | 0.0556 | 0.2881 | 0.7733 |
| 2024 | -0.0632 | 0.0460 | -1.3738 | 0.1695 |
| 2025 | -0.0111 | 0.0478 | -0.2329 | 0.8158 |
5 rows
References
- Paper Ledoit, O. and Wolf, M. (2008). “Robust Performance Hypothesis Testing with the Sharpe Ratio.” Journal of Empirical Finance, 15(5), 850-859.
- Paper Newey, W.K., & West, K.D. (1987). “A Simple, Positive Semi-Definite, Heteroskedasticity and Autocorrelation Consistent Covariance Matrix.” Econometrica, 55(3), 703-708.