Skip to content

feat(risk): stamp consecutive_losses before strategy evaluate#15

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

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

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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.

@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: 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".

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

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

Comment thread qsl.toml

[qsl.requires]
quant_platform_kit = "37c81901160c5b31127a27dba1c63944933fb6bf"
quant_platform_kit = "69a0256934d081b5ef309a885384b9eb9f62cf90"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread strategy_runtime.py
Comment on lines +55 to +58
stamped_inputs["portfolio_snapshot"] = stamp_consecutive_losses_on_snapshot(
snapshot,
strategy_profile=self.profile,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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>
@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.

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