Skip to content

Compute VWAP typical-price proxy in yfinance fallback#11

Merged
cipher813 merged 1 commit into
mainfrom
fix/yfinance-vwap-fallback
Apr 10, 2026
Merged

Compute VWAP typical-price proxy in yfinance fallback#11
cipher813 merged 1 commit into
mainfrom
fix/yfinance-vwap-fallback

Conversation

@cipher813
Copy link
Copy Markdown
Owner

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

  • `test_yfinance_fallback_populates_vwap_with_typical_price`: single-ticker path, verifies exact typical-price formula
  • `test_yfinance_fallback_vwap_not_none_multi_ticker`: MultiIndex batch path, verifies `Low <= VWAP <= High` invariant
  • Full suite: 38 passing, 0 regressions

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

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>
@cipher813 cipher813 merged commit ebe3a69 into main Apr 10, 2026
1 check passed
@cipher813 cipher813 deleted the fix/yfinance-vwap-fallback branch April 10, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant