Skip to content

[codex] Fix LongBridge paper and SG execution guards#137

Merged
Pigbibi merged 1 commit into
mainfrom
codex/fix-paper-sg-execution-guards
Jun 3, 2026
Merged

[codex] Fix LongBridge paper and SG execution guards#137
Pigbibi merged 1 commit into
mainfrom
codex/fix-paper-sg-execution-guards

Conversation

@Pigbibi
Copy link
Copy Markdown
Collaborator

@Pigbibi Pigbibi commented Jun 3, 2026

Summary

  • Change LongBridge cash-sweep/BOXX buys to use broker-validated marketable limit orders instead of raw market buys.
  • Add paper/dry-run execution dedup markers and prior-report fallback so the same signal/effective date is not executed repeatedly.
  • Localize dashboard diagnostic lines before rendering notifications, fixing mixed Chinese/English output like regime=risk_on in PAPER messages.

Root Cause

  • BOXX safe-haven buys could still be submitted as market orders, which LongBridge can reject when buying-power holds or market-order buffers exceed local cash estimates.
  • Monthly/windowed paper signals had no persisted execution marker, so a previously previewed signal could keep running inside the execution window.
  • Dashboard text bypassed the notification localization path, so raw strategy diagnostics leaked into Chinese notifications.

Validation

  • PYTHONPATH=/home/ubuntu/Projects/QuantPlatformKit/src python - <<'PY' ... renderer localization smoke ... PY
  • python -m pytest tests/test_rebalance_service.py tests/test_runtime_composer.py tests/test_request_handling.py -q
  • python -m ruff check notifications/renderers.py tests/test_notifications.py application/execution_state.py application/rebalance_service.py application/execution_service.py application/runtime_composer.py application/runtime_dependencies.py notifications/telegram.py tests/test_rebalance_service.py tests/test_runtime_composer.py

@Pigbibi Pigbibi merged commit 1d73e60 into main Jun 3, 2026
1 check passed
@Pigbibi Pigbibi deleted the codex/fix-paper-sg-execution-guards branch June 3, 2026 20:22
Copy link
Copy Markdown

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

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: 52628ca392

ℹ️ 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 on lines +273 to +274
try:
execution_already_recorded = bool(execution_state_store.has_marker(execution_marker_key))
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 Reserve execution markers atomically before submitting orders

When two Cloud Run requests/retries for the same signal overlap, both can pass this has_marker() check before either has recorded the marker, then both enter execute_rebalance_cycle and submit the same live orders. The marker write happens only after execution and uses a normal overwrite, so it does not act as a lock or create-if-absent reservation; the duplicate-run guard is therefore ineffective exactly in the concurrent invocation scenario it needs to protect. Use an atomic create/reservation step (e.g. GCS generation precondition / local exclusive create) before order submission and treat an already-existing marker as a skip.

Useful? React with 👍 / 👎.

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