Denoised and Detoned Covariance

The Denoised and Detoned Covariance first denoises the correlation matrix, replacing the eigenvalues that random returns alone could produce by their average, and then removes its first principal components, the market, in the order of López de Prado (2020, section 2.6).

The formula for the Denoised and Detoned Covariance starts from the denoised correlation matrix \(C_{d}\), the sample correlation matrix (ddof=1) with its eigenvalues below the Marcenko-Pastur upper edge averaged and rescaled to a unit diagonal, and its eigenvalues \(\mu_{k}\) and eigenvectors \(u_{k}\), largest first, and removes the first m of them:

\[G = C_{d} - \sum_{k=1}^{m} \mu_{k} \cdot u_{k} \cdot u'_{k}\]

It rescales the result to a unit diagonal with the sample standard deviations \(s_{i}\):

\[\Sigma_{i,j} = \frac{G_{i,j} \cdot s_{i} \cdot s_{j}}{\sqrt{G_{i,i} \cdot G_{j,j}}}\]

It shows the structure beyond the market with the noise removed; like the Detoned Covariance, it is singular and suits clustering rather than optimization.

Its parameters can be set, and it can be shown as a correlation matrix. The covariance matrix holds the variance of every asset and the covariance of every pair, the risk input of the mean-variance analysis of Markowitz (1952). With N assets it holds N (N + 1) / 2 numbers to estimate, and when N is not small compared to the number of periods T, the sample estimate is noisy and ill-conditioned: its smallest eigenvalues come out too small, and an optimizer that inverts it puts large weights on the combinations of assets that only look safe in the sample. The estimators differ in how they deal with this: by shrinking towards a structured target, by cleaning the eigenvalues, by weighting recent periods, by counting only large moves or by resisting outliers. Every estimate is annualized with the number of periods in a year.

Also known as: denoised detoned correlation.

In the Finance Toolkit this is get_covariance_estimate with method="denoised_detoned", the same function as Covariance Estimate.

Example · AAPL, MSFT, JNJ, XOM · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_covariance_estimate:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT", "JNJ", "XOM"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.portfolio.get_covariance_estimate(method="denoised_detoned")

Which returns:

References

  • Paper López de Prado, M. (2020). “Machine Learning for Asset Managers.” Cambridge University Press, chapter 2.
Share