A past date (and any overnight hold) showed fabricated P&L: realized was
computed as broker_day - unrealized, where unrealized was a position's FULL
mark-vs-entry. A position opened days ago still carried its whole mark, so a $0
holiday read as "+$330 realized / -$330 unrealized" on EVERY day — the same
number leaking across the date picker.
Fix: the day's P&L decomposes as broker_day = realized + (U_eod - U_sod). Added
a start-of-day baseline (the latest positions snapshot strictly before the day
begins; today's midnight for live) and subtract it, so only the day's own
open-position move counts. total = realized + unrealized now holds by
construction. Live is unaffected on a normal day (EOD flatten => no overnight
positions => U_sod=0); it only changes genuine overnight holds / past days.
Also expose `open_unrealized_pnl` (the full current mark) for the positions UI.
Verified on live data: the +$330 leak is gone — 6/20 (Sat) reads 0/0/0, 6/18
reads a real -$2368 day with a sensible split. Tests: carry-netting regression
+ the broker-delta test scoped to its own day.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>