quantlab.portfolio.predefined.ledoit_wolf#

A Ledoit-Wolf shrunk sample covariance of trailing one-bar returns.

LedoitWolfEstimator estimates the covariance of one-bar returns at a bar from the lookback_bars returns ending there, shrunk toward a scaled identity with the Ledoit-Wolf coefficient, so the estimate stays well conditioned when there are more symbols than bars. The shrunk covariance is split into correlations and volatilities, and the volatilities can be replaced by given ones (a model’s forecast) before it is put back together. It is kept in low-rank form, the scaled window plus a diagonal, never as the dense [n, n] matrix (shrunk_low_rank, which the approximate backtest’s batched estimate shares).

Classes

LedoitWolfEstimator

Ledoit-Wolf shrunk covariance of the trailing one-bar returns.

Functions

shrunk_low_rank

Return (a, U) with a I + U U' each bar's Ledoit-Wolf estimate over its covered symbols.