1.9 KiB
Prompt
The human requested documentation and tests for maybe_fill_null_segments(), identifying its flat OHLC fallback and asking how packed SHM could accept later recovered bars.
Code output
git diff 1da9b760 -- piker/tsp/_history.py
git diff 1da9b760 -- tests/test_history_backfill.py
Document the existing slot-based repair and its limitations. Extend fallback coverage to NoData and DataUnavailable; verify the observed packed MNQ gap remains unchanged. Reproduce the relative-tolerance failure at a modern epoch, then disable relative tolerance in the synthetic timestamp boundary check.
Validation
Before the fix: modern-epoch boundary case failed, zero-epoch case passed. The overfull synthetic run duplicated the right bar. After the fix: 15 backfill tests passed in 1.99s.
Close-copy factoring follow-up
The human requested stronger internal types, a reusable close-copy helper, searchable comments for copying close and synthesizing stamps, and research into historical venue closure queries. Extracted _copy_close_to_null_rows(), preserving non-OHLC fields and rejecting occupied slots before mutation. Added explicit callback, array, segment-index and date annotations. Preserved the existing provenance TODO and suggested avoiding volume sentinels. Four helper cases cover successful fill and unchanged rejected inputs. Backfill suite: 19 passed in 2.01s; Ruff and diff check pass.
IB documents historical SCHEDULE requests separately from contract hours. The installed ib_async exposes reqHistoricalScheduleAsync. No live schedule request or venue behavior change was performed. Source: https://interactivebrokers.github.io/tws-api/historical_bars.html