Coming soon — expected the week of August 18, 2026.
When a position's entry and its exit land in different trading sessions, a trade matcher scoped to a single session doesn't just lose the trade — it invents one in its place. The orphaned exit looks like an opening leg, and the next genuine entry gets paired against a position that never existed.
This post is the fix. Determining how far back the lookback window has to reach — not an arbitrary “one session,” but backward to the last point the account was genuinely flat. FIFO lot matching that runs forward from that boundary across however many session rotations it crosses. The attribution rule that decides which session owns a split trade's P&L, and why the obvious answer is the wrong one. And the nullable foreign key that lets orders exist before the trade they belong to does.
The companion to Calculating P&L When a Trade Spans Two Trading Sessions, which covers the problem this one solves. Part of the same arc as The Hidden Problem With Futures Automation: Contracts Expire and The Contract Roll State Machine.