refactor(risk_model): consume alpha_engine_lib.quant.factor_risk_xs (shared factor-risk engine)#236
Merged
Merged
Conversation
…ia shim The C.2a factor-risk math (cross-sectional Fama-MacBeth Σ=B·F·Bᵀ+D builder) was lifted to the shared alpha-engine-lib (LV1-AE leverage arc) so the predictor and robodashboard consume one engine. risk_model/__init__.py is now a re-export shim over alpha_engine_lib.quant.factor_risk_xs — training/risk_model_persist.py and all other consumers keep working unchanged; numerics are identical (sklearn LedoitWolf preserved verbatim). - requirements.txt + requirements-lambda.txt: bump lib pin v0.42.0 -> v0.47.0 (lockstep test enforces match); root adds the [quant-xs] extra (pandas+sklearn, already predictor deps), Lambda keeps leaner extras (inference doesn't import risk_model). - Delete tests/test_risk_model.py — canonical math tests now live in the lib (test_quant_factor_risk_xs.py). test_risk_model_persist.py already exercises the real build_factor_risk_model through the shim end-to-end. - Add tests/test_risk_model_lib_contract.py — consumer-contract wiring + smoke. Suite: 1359 passed. Does NOT wire portfolio_risk/tracking_error into solve_target_weights (that stays C.3-gated). GATED on alpha-engine-lib#91 merging -> v0.47.0 tag + PyPI publish (the git-tag pin resolves then). Validated locally against an editable lib install. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
|
CI red here is the tag-gate, not a code defect. Local validation against an editable install of the lib branch is green: the CI suite (1359 tests) passes, numerics identical (sklearn LedoitWolf preserved). Converted to draft until the gate clears:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The C.2a factor-risk math (cross-sectional Fama-MacBeth
Σ=B·F·Bᵀ+Dbuilder) is lifted to the shared alpha-engine-lib (alpha_engine_lib.quant.factor_risk_xs) as the LV1-AE leverage step, so the predictor and robodashboard consume one engine.risk_model/__init__.pyis now a re-export shim —training/risk_model_persist.pyand all consumers keep working unchanged.LedoitWolfpreserved), so persisted F/D are unchanged.requirements.txt+requirements-lambda.txt: lib pin v0.42.0 → v0.47.0 (lockstep test enforces match). Root adds the[quant-xs]extra (pandas+sklearn — already predictor deps); the Lambda keeps leaner extras (inference doesn't importrisk_model).tests/test_risk_model.py— canonical math tests now in the lib (test_quant_factor_risk_xs.py).test_risk_model_persist.pyalready exercises the realbuild_factor_risk_modelthrough the shim end-to-end.tests/test_risk_model_lib_contract.py— consumer-contract wiring + smoke.Verification
--ignore test_inference/test_modelset): 1359 passed, validated against an editable install of the lib branch.portfolio_risk/tracking_errorintosolve_target_weights— that stays C.3-gated.Depends on cipher813/alpha-engine-lib#91 (adds
factor_risk_xs+ bumps to 0.47.0). The predictor pins the lib by git tag, so the@v0.47.0pin resolves only after #91 merges →auto-tagcreatesv0.47.0. Merge #91 first, then this.Follow-ups (filed)
factor_risk.ledoit_wolf_covvs sklearnfactor_risk_xs) — numerics-affecting, needs its own validation.xs-output → FactorRiskModelbridge so Option-A feedsportfolio_risk/tracking_errordirectly (no consumer until C.3 wiring).🤖 Generated with Claude Code