Repository navigation
fix(risk): harden DCA comparator comparability and SMA regime fail-closed guards - #823
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
c5adcb2 to
1b497d2
Compare
|
@codex review |
AI Code Review (gemini /
|
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
AI Code Review (gemini /
|
AI assistance
This PR was drafted with AI coding assistance and reviewed locally via pytest, ruff, and Codex adversarial audit findings before pushing.
What changed
SmaHysteresisRegimeConfig.sma_windowvalidation insrc/quant_platform_kit/risk/benchmark_dca_and_regime.pyto requireisinstance(sma_window, int)(rejecting booleans and floats like200.0).is_valid: bool = TruetoSmaHysteresisRegimeDecisionand forceexposure_multiplier = 0.0(withis_valid=False) onINSUFFICIENT_HISTORY_FAIL_CLOSEDandINVALID_PRICE_FAIL_CLOSED, keeping invalid-data fail-closed strictly separate from validBELOW_LOWER_SMA_BAND(cfg.risk_off_multiplier).valuation_session_datevalidation onevaluate_matched_cashflow_dca_benchmark/MatchedCashflowDcaReport, separatetotal_deposits_usdandtotal_withdrawals_usd, returnNonefor undefined multiples/percentages when net invested or benchmark ending value<= 0, and requirecomparable(total_deposits_usd > 0 and ending_value_usd > 0across all benchmarks) beforebeats_all_benchmarkscan beTrue.tests/test_benchmark_dca_and_regime.pyto cover floatsma_windowrejection, non-zerorisk_off_multipliervs invalid-data fail-closed isolation, valuation-date mismatch rejection, and zero-cashflow comparability.How verified
uv run pytest tests/test_benchmark_dca_and_regime.py tests/test_twr_capital_ladder.py -q->9 passed in 3.07suv run ruff check src/quant_platform_kit/risk/benchmark_dca_and_regime.py tests/test_benchmark_dca_and_regime.py->All checks passed!Why
Address all P1/P2 findings from the post-merge audit on
benchmark_dca_and_regime.pyso zero-cashflow benchmarks cannot produce false wins, valuation dates stay synchronized fail-closed, and invalid price/history inputs always drop exposure to0.0regardless ofrisk_off_multiplier.Risk
live=OFF,paper=OFF).is_valid,valuation_session_date,total_deposits_usd,total_withdrawals_usd,comparable, nullableending_multiple/alpha_vs_benchmark_pct) only affect new callers of the module merged in#822.