Compute VWAP typical-price proxy in yfinance fallback#11
Merged
Conversation
When polygon.io fails (rate limit hit, auth failure, or empty response
for the requested date), daily_closes falls back to yfinance. The old
fallback set VWAP=None on every row, which caused the executor's
load_daily_vwap() to emit "daily_closes/{date} has no VWAP column —
skipping" for up to 5 consecutive days — the full lookback window —
whenever polygon was unhealthy. The executor then had no VWAP reference
for its intraday entry triggers.
Root cause surfaced during 2026-04-10 incident investigation: the
executor dry-run showed "No daily_closes with VWAP found in last 5 days"
after polygon had been returning empty results since ~04-06.
Fix: compute a typical-price VWAP proxy as (High + Low + Close) / 3.0
in the yfinance fallback. yfinance does not expose true intraday VWAP
for free, so this is the standard pre-tick-data approximation. The
executor uses daily VWAP as a prior-day reference level (not an
intraday streaming value), so the proxy is accurate enough for the
entry-trigger use case and materially better than None.
Regression test pins both the single-ticker path and the MultiIndex
multi-ticker path yfinance returns for batch downloads. Asserts
VWAP is non-None and satisfies Low <= VWAP <= High.
This does not fix whatever is wrong with polygon.io — that's a separate
investigation. Once polygon is healthy again, it will still be the
primary source (true intraday VWAP from the grouped-daily endpoint).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
When polygon.io fails (rate limit hit, auth failure, or empty response), `daily_closes` falls back to yfinance. The old code set `VWAP=None` on every yfinance row, causing the executor to emit `No daily_closes with VWAP found in last 5 days` whenever polygon was unhealthy — as happened today (2026-04-10), with VWAP missing from 04-06 through 04-10.
Fix
Compute a typical-price VWAP proxy as `(High + Low + Close) / 3.0` in the yfinance fallback. yfinance doesn't expose true intraday VWAP for free, so this is the standard pre-tick-data approximation. The executor uses daily VWAP as a prior-day reference level (not streaming intraday), so the proxy is accurate enough for the entry-trigger use case.
Test plan
Not in scope
This does not diagnose or fix whatever is wrong with polygon.io. Once polygon is healthy again (free-tier rate limit reset, or key refresh), it will still be the primary source with true intraday VWAP from the grouped-daily endpoint. Worth a separate investigation if polygon continues returning empty results past Monday.
🤖 Generated with Claude Code