Skip to content

fix(flex): accept US overnight executions dated to the next day - #1028

Merged
Pigbibi merged 2 commits into
mainfrom
ccr-9b5ac466-zqt5sn
Nov 26, 2026
Merged

Pigbibi merged 2 commits into
mainfrom
ccr-9b5ac466-zqt5sn

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

AI assistance

Claude Code (Anthropic) made the change. Local Codex CLI (gpt-6.2-astra, reasoning high) reviewed it in two rounds. The round-1 P2/P3 findings are fixed; round 2 raised only P2s, which are listed under Risk.

What changed

ibkr_flex_executions._local_time no longer requires every execution's dateTime to share its tradeDate. It also accepts the US 23/5 overnight shape: dateTime at or after 20:00 on the calendar day immediately before tradeDate, on a Sunday–Thursday evening, for a USD stock (currency == "USD", assetCategory == "STK").

  • The date gap is computed by subtraction, so a far-future dateTime cannot overflow and abort the whole ledger.
  • Records are unchanged. local_time keeps the local wall time and time_zone stays None, so the record schema and its consumers' closed key sets are untouched.
  • Every other mismatch still makes the execution source source_unavailable with execution_datetime_invalid, exactly as before.
  • Tests cover the accepted cases (20:00 boundary, 23:59:59, Sunday→Monday, after-midnight same date) and the rejected ones (19:59:59, two-day gap, local after trade date, Friday and Saturday evenings, far-future overflow, HKD and non-stock rows).

Assumption: Flex dateTime is in US Eastern time. The report does not state the zone; this must be confirmed against the account's Flex query settings or a real report before live reconciliation (SUPPLY-B).

How verified

  • uv run --no-sync python -m pytest -q tests: 6876 passed, 7 skipped.
  • uv run --no-sync ruff check --exclude external .: clean. bash tests/test_sync_cloud_run_env_workflow.sh: PASS.

Why

IBKR dates US overnight fills from 20:00 ET to midnight on the following day, and the US 23/5 trading boundary takes effect on 2026-12-06. Before this change, a single such execution, from a manual or broker-side overnight trade, would make the whole Flex execution source unavailable and stop reconciliation. The system itself places no overnight orders (FUSE C-FUSE-GATE blocks them).

Merge order: merge after QuantRuntimeSettings accepts the same shape in its broker_executions.v1 consumers (companion PR), so the console never rejects what this producer emits.

Risk

  • Tier: R2 / high-risk execution repo. Parsing is relaxed only for the narrow US overnight shape; there are no order, broker-connection or runtime-config changes.
  • Known follow-ups (P2), not addressed here:
    • gate on the execution venue (listing or exchange) rather than currency and asset class alone;
    • confirm the Flex report time zone (see Assumption);
    • exclude market holidays as overnight trade dates.

Generated by Claude Code

Pigbibi and others added 2 commits November 26, 2026 05:16
IBKR dates fills from 20:00 ET to midnight on the following day. The
Flex execution parser required dateTime to share tradeDate, so one
overnight fill made the whole execution source unavailable. Accept a
dateTime on the evening before tradeDate at or after 20:00, assuming
Eastern-time Flex timestamps; other mismatches still fail closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdZHqdsDyVsVxzUJLA
Allow the next-day trade date only for USD stock executions on
Sunday to Thursday evenings, the only US overnight sessions, and
compare the date gap by subtraction so far-future timestamps cannot
overflow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdZHqdsDyVsVxzUJLA
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T05:33:23.421526Z 443addc PR opened
🔒 Security Review ✅ Completed 2026-11-26T05:34:04.737621Z 443addc PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Pigbibi Pigbibi added the agent-approved An agent cleared this high-risk change on the current head; not an owner confirmation label Nov 26, 2026 — with Claude
@Pigbibi
Pigbibi merged commit fb8227d into main Nov 26, 2026
16 of 17 checks passed
@Pigbibi
Pigbibi deleted the ccr-9b5ac466-zqt5sn branch November 26, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-approved An agent cleared this high-risk change on the current head; not an owner confirmation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant