Repository navigation
fix(uw-alpha): page dark/lit prints back to the session's first print - #546
Merged
Merged
Conversation
capture_dark_lit_for fetched one 500-print page per ticker, day and source. UW serves newest first, so busy names kept only the after-hours tail (NVDA 2026-09-15: ~13,500 dark prints, 500 stored). Page with older_than until a short page or a prior-ET-date print, capped at 60 pages per source (WARN + page_cap_hits). The cursor re-reads the boundary second because older_than is strict and timestamps are whole seconds; the PK drops the repeats. Prints are kept only when their ET date is the market date, since UW's date window carries the prior session's after-hours tail. The healer's dark/lit estimate rises 2 -> 10 calls per item; the catch-up script charges real pages. The nightly summary reports pages and page_cap_hits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
capture_dark_lit_forasked UW for one page (limit=500) per ticker, day and source. UW serves prints newest first, so busy names kept only the after-hours tail. NVDA 2026-09-15: about 13,500 dark prints at UW, 500 stored. September cut rate (argon-8b, prod read-only): dark 45.6% of ticker-days, lit 20.9%.What changes
sources/uw.py:fetch_darkpool_prints/fetch_lit_flowtake an optionalolder_than(new_print_page_fetcher; the pinned surface fixture is regenerated on purpose, +2 request cases that pin the param).uw_alpha_capture._fetch_print_daypages each source until:limit, orpage_cap_hits). Worst case is 2 × 60 = 120 UW calls per ticker-day.executed_at's ET date equalsmarket_date. Every stored row already satisfies this (prod: 2,031,461 rows with market_date ≥ 2026-09-01, 100% same ET date).Two UW behaviours measured live (2026-10-05, NVDA 2026-09-15, 5 calls)
older_thanstrictnessolder_than=19:58:12Zreturned 12lit-flowhonoursolder_thanSo a strict cursor drops prints at every page boundary. The cursor is last-second + 1 s; the overlap is re-read and the PK
(source, tracking_id, executed_at, price, size, volume)+ON CONFLICT DO NOTHINGdrops repeats. If a full page sits inside the overlap second (no progress), it steps strictly once.Callers
dark_lit_capture: summary now carriespagesandpage_cap_hits. Its UW cost rises from 2 calls per ticker to the real page count; it stays unbudget-gated as before (durable data).uw_alpha_dark_lit): the healer charges a fixedest_per_itemfor every dataset, not real calls. Raised 2 → 10 (typical day; sampled dark CRM 3, PLTR 7, DELL 13 pages; lit 1–2). Not an upper bound. The healer dispatches only missing ticker-days, so already-cut days are not re-healed here; that is the history backfill (follow-up PR).scripts/backfill/uw_alpha_catchup.py: estimate 10 for the pre-check and dry run; a live run charges the pages actually fetched, including pages fetched before a failure.Tests
tests/unit/worker/test_dark_lit_paging.py: a stub with UW's measured semantics (newest first, strictolder_than, 3 prints per second,limit=7so every boundary splits a second, prior-session tail).test_uw_alpha_capture,test_uw_historical_alpha_repository, catch-up, surface): 433 passed.ruff check src/ tests/ scripts/clean.🤖 Generated with Claude Code