Skip to content

refactor(quant): unify Ledoit-Wolf onto one impl (LV1-AE.a)#95

Merged
cipher813 merged 1 commit into
mainfrom
feat/unify-ledoit-wolf
Jun 3, 2026
Merged

refactor(quant): unify Ledoit-Wolf onto one impl (LV1-AE.a)#95
cipher813 merged 1 commit into
mainfrom
feat/unify-ledoit-wolf

Conversation

@cipher813
Copy link
Copy Markdown
Owner

What

LV1-AE.a — kills the duplicate Ledoit-Wolf reimplementation (audit finding #2). The lib hosted two: the numpy quant.factor_risk.ledoit_wolf_cov (Option B) and sklearn LedoitWolf inside quant.factor_risk_xs.estimate_factor_covariance (Option A).

Validated numerically identical — max abs diff ~1e-21 across n∈[35,1000] (both center the data + estimate the same shrinkage intensity toward a scaled-identity target). So the factor_risk_xs ledoit_wolf branch now calls the shared numpy ledoit_wolf_covone LW impl in the lib. sklearn stays a lazy import for the OAS branch only.

Risk

Zero numerics change. The predictor's persisted F is identical to ~1e-21, and there's no live consumer of F anyway (the C.3 solve_target_weights read is gated). Predictor adopts on its next lib-pin bump; no forced re-pin.

Changes

  • factor_risk_xs.estimate_factor_covariance: ledoit_wolf → shared numpy impl.
  • version 0.50.0 → 0.51.0; +1 consolidation-contract test. Full suite: 1107 passed.

🤖 Generated with Claude Code

The lib hosted two Ledoit-Wolf shrinkage estimators: the numpy hand-rolled
quant.factor_risk.ledoit_wolf_cov (Option B) and sklearn LedoitWolf inside
quant.factor_risk_xs.estimate_factor_covariance (Option A). Validated they are
numerically identical (max abs diff ~1e-21 across n∈[35,1000]; both center +
estimate the same shrinkage intensity toward scaled identity).

So the xs ledoit_wolf branch now calls the shared numpy ledoit_wolf_cov — one LW
impl in the lib. sklearn stays a lazy import for the OAS branch only. Zero
numerics change (the persisted predictor F is identical to ~1e-21; no live
consumer of F anyway — C.3 solve is gated). Closes audit finding #2.

- 0.50.0 -> 0.51.0; +1 consolidation-contract test; suite 1107.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cipher813 cipher813 merged commit 0a8179b into main Jun 3, 2026
6 checks passed
@cipher813 cipher813 deleted the feat/unify-ledoit-wolf branch June 3, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant