feat(risk): stamp consecutive_losses before strategy evaluate - #112
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. |
Co-Authored-By: Claude <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 06eba91ea9
ℹ️ 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=53b2ca73a5a50257b5d1a3c769b75c40924e4ba6#53b2ca73a5a50257b5d1a3c769b75c40924e4ba6" } | ||
| source = { git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=69a0256934d081b5ef309a885384b9eb9f62cf90#53b2ca73a5a50257b5d1a3c769b75c40924e4ba6" } |
There was a problem hiding this comment.
Lock QPK to the resolved 69a0256 commit
In frozen installs from this lockfile, uv still resolves quant-platform-kit to the fragment commit 53b2ca73... (I checked uv sync --frozen --no-dev -v, which reports quant-platform-kit @ ...@53b2ca73...). That older QPK revision does not contain stamp_consecutive_losses_on_snapshot, so the new import in strategy_runtime.evaluate() will fail before any strategy can evaluate in the CI/runtime/watchdog environments that install from uv.lock. Regenerate the lock so the source fragment also points at 69a0256934d081b5ef309a885384b9eb9f62cf90.
Useful? React with 👍 / 👎.
| portfolio_snapshot = stamp_consecutive_losses_on_snapshot( | ||
| portfolio_snapshot, | ||
| strategy_profile=self.profile, | ||
| domain="crypto", | ||
| logger=getattr(self, "logger", None), |
There was a problem hiding this comment.
Honor rejected risk gates before executing plans
When this stamp produces consecutive_losses > 5, the QPK risk gate rejects the decision by clearing positions and setting risk_flags, but the platform still maps diagnostics/budgets into executable rotation and DCA plans (decision_mapper.py) and application/execution_service.py executes those planned buys without checking risk_flags. In that loss-streak scenario, the new circuit breaker can appear in diagnostics while orders continue to be placed, so this call needs a platform-side stop for rejected decisions before mapping/execution.
Useful? React with 👍 / 👎.
|
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