feat(risk): stamp consecutive_losses before strategy evaluate#15
Conversation
Reuse QPK stamp helper so entrypoint circuit breakers see trailing loss streak from live equity history. Co-Authored-By: Claude <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d3b758498
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| name = "quant-platform-kit" | ||
| version = "0.10.0" | ||
| source = { git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=37c81901160c5b31127a27dba1c63944933fb6bf#37c81901160c5b31127a27dba1c63944933fb6bf" } | ||
| source = { git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=69a0256934d081b5ef309a885384b9eb9f62cf90#37c81901160c5b31127a27dba1c63944933fb6bf" } |
There was a problem hiding this comment.
Fix the stale locked QPK commit
When installs use the checked-in lockfile, this still resolves QuantPlatformKit to the old commit: I checked uv export --locked --format requirements-txt, and it emits quant-platform-kit @ ...@37c81901160c5b31127a27dba1c63944933fb6bf. Since strategy_runtime.py now imports the new stamp_consecutive_losses_on_snapshot helper from the bumped QPK revision whenever a portfolio snapshot is present, locked CI/deploy environments can still install the old package and fail at runtime instead of evaluating the strategy.
Useful? React with 👍 / 👎.
|
|
||
| [qsl.requires] | ||
| quant_platform_kit = "37c81901160c5b31127a27dba1c63944933fb6bf" | ||
| quant_platform_kit = "69a0256934d081b5ef309a885384b9eb9f62cf90" |
There was a problem hiding this comment.
Update the QSL metadata test with the new pin
This pin change leaves tests/test_qsl_metadata.py:18 still asserting the previous QuantPlatformKit hash (37c81901160c5b31127a27dba1c63944933fb6bf), so the QSL metadata test will fail as soon as the test environment has its normal dependencies installed. Please update the expected value alongside this metadata bump so CI reflects the new required bundle revision.
Useful? React with 👍 / 👎.
| stamped_inputs["portfolio_snapshot"] = stamp_consecutive_losses_on_snapshot( | ||
| snapshot, | ||
| strategy_profile=self.profile, | ||
| ) |
There was a problem hiding this comment.
Expose the stamped portfolio to strategy context
For the QMT profiles currently loaded through load_strategy_runtime_adapter_for_profile, the pinned CnEquityStrategies adapters leave portfolio_input_name unset and their manifests require market_history, so QPK's context builder ignores this extra portfolio_snapshot key instead of assigning it to ctx.portfolio. In the normal dry-run path (application/dry_run_service.py adds the snapshot as an extra input), this means the consecutive-loss metadata is stamped into a value that the enabled strategies never receive, so the intended circuit breaker still cannot trip even when live equity history exists.
Useful? React with 👍 / 👎.
Co-Authored-By: Claude <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Co-Authored-By: Claude <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Co-Authored-By: Claude <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Summary
consecutive_lossesontoportfolio_snapshotbefore strategy evaluate via QPKstamp_consecutive_losses_on_snapshot69a0256(QPK #211)Test plan
Made with Cursor