Skip to content

fix(executions): accept IBKR overnight fills dated to the next day - #1228

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

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

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

AI assistance

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

What changed

The broker_executions.v1 consumers now accept a US 23/5 overnight fill. Such a fill's local_time falls on the calendar day immediately before its trade_date, at or after 20:00, in Eastern time:

  • New application/account_facts/trade_date_boundary.js holds the shared rule localTimeMatchesTradeDate(localDay, time, tradeDate, timeZone). It strictly rejects impossible dates such as 2026-09-31. The rollover applies only when time_zone is null (the Flex producer's Eastern assumption) or America/New_York; any other explicit zone keeps the same-day rule.
  • account_facts/executions.js (normalizeExecutions) uses the shared rule in place of the strict same-day check.
  • orders_fills/normalize.js (adaptLegacyBrokerExecutionPayload) accepts the same shape and derives executed_at for an overnight fill from its local calendar date, not its trade date.
  • Tests: broker_executions_validation.mjs covers the accepted boundary and Sunday→Monday cases, plus rejections for 19:59, a two-day gap, local after trade date, an impossible date and explicit non-Eastern zones. sa2_orders_fills_validation.mjs checks the adapter's executed_at (2026-10-22T20:30 ET → 2026-10-23T00:30:00.000Z) and its rejections.

Compatibility: the change only relaxes consumers, so payloads that were valid stay valid. This PR must merge before the matching producer change in InteractiveBrokersPlatform, which starts emitting such rows.

How verified

  • node tests/broker_executions_validation.mjs, sa2_orders_fills_validation.mjs, sa2_demo_validation.mjs, sa2_deployable_capital_validation.mjs, account_identity_inventory_validation.mjs, console_execution_evidence_validation.mjs: PASS.
  • node tests/read_contract_boundaries_validation.mjs: PASS. npm run test:operations --prefix web/strategy-switch-console: PASS.
  • The full CI js command list from validate.yml passes locally, except five release-history scripts that need a full-depth clone (they also fail on unchanged main in a shallow checkout).
  • git diff --check: clean.

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. With the old strict same-day check, a single such row made the whole execution history invalid.

Risk

  • Tier: R2 (account-fact contract consumer). The rule only relaxes validation, for one narrow shape.
  • Known follow-ups (P2), not addressed here:
    • the trades table shows trade_date beside the local clock time, so an overnight fill appears on its booking date (frontend);
    • recognising Eastern aliases such as US/Eastern;
    • time-only overnight rows in the adapter;
    • checking time and zone together when merging reports.

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
broker_executions.v1 consumer required local_time to share the trade
date, so one overnight fill would reject the whole execution history.
Also accept a local_time on the evening before the trade date at or
after 20:00; every other mismatch is still rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdZHqdsDyVsVxzUJLA
- Move the overnight trade-date rule into a shared module, used by
  both the executions store and the legacy orders/fills adapter.
- Reject impossible local dates, and allow the rollover only for a
  null (Eastern) or America/New_York time zone.
- Derive an overnight fill's executed_at from its local date.

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:39:28.918721Z d36993c Manual request
🔒 Security Review ✅ Completed 2026-11-26T05:41:07.176419Z d36993c Manual request
ℹ️ 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.

@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: 27cac39c8e

ℹ️ 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".

The trades table and cards showed trade_date beside the local clock,
so an overnight fill booked on the next trade date looked a day late.
Show the local date with the clock when it differs from the trade date.
Regenerate the embedded v2 asset map.

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

Pigbibi commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: d36993c35a

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: d36993c35a

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@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 d73e207 into main Nov 26, 2026
24 of 25 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