Skip to content

feat(risk): stamp consecutive_losses before strategy evaluate - #112

Merged
Pigbibi merged 3 commits into
mainfrom
feat/wire-consecutive-losses-metadata
Jul 9, 2026
Merged

feat(risk): stamp consecutive_losses before strategy evaluate#112
Pigbibi merged 3 commits into
mainfrom
feat/wire-consecutive-losses-metadata

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Stamp consecutive_losses onto portfolio_snapshot before strategy evaluate via QPK stamp_consecutive_losses_on_snapshot
  • Bump QPK pin to 69a0256 (QPK #211)
  • Entrypoint risk gates can trip the >5 consecutive-loss circuit breaker once live equity history exists

Test plan

  • Local stamp unit test
  • CI green

Made with Cursor

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>
@cursor

cursor Bot commented Jul 9, 2026

Copy link
Copy Markdown

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>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread uv.lock
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" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread strategy_runtime.py
Comment on lines +241 to +245
portfolio_snapshot = stamp_consecutive_losses_on_snapshot(
portfolio_snapshot,
strategy_profile=self.profile,
domain="crypto",
logger=getattr(self, "logger", None),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@cursor

cursor Bot commented Jul 9, 2026

Copy link
Copy Markdown

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>
@cursor

cursor Bot commented Jul 9, 2026

Copy link
Copy Markdown

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.

@Pigbibi
Pigbibi merged commit 6653c14 into main Jul 9, 2026
2 checks passed
@Pigbibi
Pigbibi deleted the feat/wire-consecutive-losses-metadata branch July 9, 2026 23:29
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