Commit Graph

2 Commits (e11d7af2b1a9d7aa48a69fbe3ef574cbeb270aba)

Author SHA1 Message Date
Gud Boi 24943e3ee2 Limit IB trade filtering to its startup backlog
The timestamp guard matched live trades against `samplerd`'s 1s row
labels and waited for the next slot before quote fanout. Rounded
timestamps misclassified valid ticks, and steady-state receipt-time
matching was not the existing current-tail sampling contract.

Replace it with a temporary IB startup policy in
`piker.brokers.ib._util.StartupTradeFilter`. Capture local receipt
time when consumption starts; exclude older stamped packets until
the first post-start trade for each symbol. Then stop interpreting
timestamps and apply trades to the current SHM tails before notify.
Unstamped ticks remain admissible without ending the startup check.

Move epoch-unit conversion, catch-up state and diagnostics into the
backend utilities. The generic sampler only conditionally invokes
the helper for IB. Other providers retain receipt-time sampling.

Replace slot-matching tests with coverage for startup exclusion,
equal/half-second boundaries, delayed stamps after catch-up and
invalid/missing stamps. Hold rows ahead of or behind tick time;
require no sampler wait and check both SHM writes at notification
for admitted trades.

This excludes an observed startup prefix; it does not reconcile or
exactly deduplicate overlapping provider history. Keep that fuller
startup handoff separate, without changing `samplerd`'s clock
or introducing a queued writer which can notify before SHM updates.

Regressed-by: 31c0a366 (steady-state sampler timestamp guard)
Found-via: live MNQ/QQQ delay warnings and stalled quote delivery

(this patch was generated in some part by `opencode` using
`gpt-6.1-sol` (`openai`))
2026-11-27 12:42:20 -05:00
Gud Boi 5c16fa066c Skip stale trade ticks in 1s sampler
Queued IB startup trades can arrive after samplerd has advanced
the current 1s bar. Writing them into that bar creates a false
price and volume spike. Compare each stamped trade with the
current bar before updating either SHM buffer. Warn whenever a
next-slot trade must wait for samplerd; skip other mismatches
and leave untimestamped feeds on the receive-time path.

Add focused tests for epoch units, queued trades, and warning
before the next-slot wait. Note that incomplete provider bars
still need a correction path for late trades.

Prompt-IO: ai/prompt-io/codex/20260925T190523Z_c0dae89a_prompt_io.md

(this patch was generated in some part by `codex` using `gpt-6` (`openai`))
2026-11-27 12:42:20 -05:00