Skip to content

Silence IBKR precheck notifications and add probe#66

Merged
Pigbibi merged 2 commits into
mainfrom
fix/precheck-silent-notifications
May 18, 2026
Merged

Silence IBKR precheck notifications and add probe#66
Pigbibi merged 2 commits into
mainfrom
fix/precheck-silent-notifications

Conversation

@Pigbibi
Copy link
Copy Markdown
Collaborator

@Pigbibi Pigbibi commented May 18, 2026

Summary

This PR changes the IBKR detection paths so normal successful checks are logged and persisted without sending Telegram cycle notifications. The error handling path is unchanged, so connection failures, strategy exceptions, and probe failures still publish Telegram alerts.

Issue

The open-after-market /precheck scheduler is intended as a detection/dry-run check. It should give us machine-readable reports and Cloud Logging detail, but only page the user when something is wrong. Before this change, precheck used the same notification sink as live execution, so normal heartbeat or simulated rebalance output was sent to Telegram.

There are also Cloud Scheduler jobs calling /probe at 10:00 ET. Today those requests return 404 because the service has no probe route, so the post-open broker/account connectivity check is not actually running.

Root Cause

run_strategy_core(..., dry_run_only_override=True) built the normal rebalance runtime. That runtime always used the real notification port, so NotificationPublisher.publish(...) logged the detailed message and sent the compact Telegram message even during precheck.

The scheduler-side probe was configured before the Flask route existed in the service.

Fix

IBKRRuntimeComposer.build_rebalance_runtime() now accepts silent_cycle_notifications. The precheck path passes this flag when dry_run_only_override is set, replacing the cycle notification sink with a no-op notification port. Existing exception handlers still call publish_notification(...) directly, so failures are still surfaced.

/probe now performs a dry-run report-scoped broker connection and account snapshot check. Success records structured runtime events and an execution report without Telegram output; failure records the report and sends a health-probe alert.

Validation

  • PYTHONPATH=/home/ubuntu/Projects/QuantPlatformKit/src:/home/ubuntu/Projects/UsEquityStrategies/src python -m pytest tests/test_runtime_composer.py -q
  • python -m py_compile main.py application/runtime_composer.py notifications/telegram.py tests/test_runtime_composer.py tests/test_request_handling.py

tests/test_request_handling.py could not be run on this VPS because the local environment is missing pandas; the changed modules compile and the focused composer test passes.

@Pigbibi Pigbibi changed the title Silence IBKR precheck cycle notifications Silence IBKR precheck notifications and add probe May 18, 2026
@Pigbibi Pigbibi merged commit 531aea6 into main May 18, 2026
1 check passed
@Pigbibi Pigbibi deleted the fix/precheck-silent-notifications branch May 18, 2026 14:14
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: c9881565d6

ℹ️ 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 main.py
Comment on lines +796 to +798
@app.route("/probe", methods=["POST", "GET"])
def handle_probe():
return _handle_probe()
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 Restrict /probe execution to POST requests

The new route explicitly allows GET, but handle_probe() immediately runs _handle_probe() without a method guard, so any GET hit to /probe will open an IBKR connection, persist a dry-run report, and potentially send failure notifications. This is a production-risk side effect for routine GET traffic (health check tooling, accidental browser hits, or crawlers), and it is inconsistent with /precheck, which returns a safe message on GET instead of executing strategy logic.

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