Skip to content

fix(research): [PR3] perf-tracker yfinance fallback → daily_closes S3 (R5)#199

Merged
cipher813 merged 2 commits into
mainfrom
fix/yf-pr3-perftracker
May 17, 2026
Merged

fix(research): [PR3] perf-tracker yfinance fallback → daily_closes S3 (R5)#199
cipher813 merged 2 commits into
mainfrom
fix/yf-pr3-perftracker

Conversation

@cipher813
Copy link
Copy Markdown
Owner

yfinance-centralization arc — PR 3 (perf-tracker fallback → daily_closes S3)

Plan doc: alpha-engine-docs/private/yfinance-centralization-260516.md (item R5, PR 3). With PR1+PR2 this makes alpha-engine-research yfinance-free at runtime — the only remaining yfinance reference is local/time_scanner.py, which the plan explicitly excludes as a dev-only scanner not in the Lambda/SF path.

Exact change

scoring/performance_tracker.py::run_performance_checks — replaced the yf.download(period="2d") fallback leg with the in-repo data/fetchers/feature_store_reader.py::read_latest_daily_closes() (alpha-engine-data's staging/daily_closes/ parquet → {ticker: close}). Deleted import yfinance as yf + import pandas as pd (pandas was only used by the removed yfinance DataFrame parsing). Module docstring updated.

Polygon grouped-daily stays the PRIMARY path — completely unchanged. Only the fallback swapped. The new get_latest_price() returns polygon_prices[t] first, then daily_closes.get(t) — identical precedence to before.

Graceful-degrade preserved (all-agents-strict, #195)

  • read_latest_daily_closes() returns {ticker: close} or None and never raises (broad except → None) — strictly matches the old try/except contract. No read that degraded before now raises.
  • Both polygon and fallback empty → returns _compute_accuracy_stats() with no new evaluations recorded — identical net behavior to the old yfinance-failed branch (which proceeded with price_data=None and recorded nothing).
  • Missing-ticker → row skipped (unchanged).

Tests

Reworked tests/test_performance_tracker.py: the 5 tests that patched scoring.performance_tracker.yf.download would break (yf removed), so rewrote them to fake feature_store_reader.read_latest_daily_closes via monkeypatch (NOT unittest.mock.patch — documented full-suite bleed; mirrors tests/test_held_thesis_strict.py). Removed the now-unused yf-shaped _mock_price_data helper + pandas import. Added: module-is-yfinance-free assertion; daily_closes-fallback 10d / beat-SPY / missing-ticker evals; graceful-degrade-when-fallback-unavailable; and an explicit polygon-primary-path-unaffected test with a tripwire that fails if the fallback reader is called when polygon covers all tickers. test_archive.py references performance_tracker only in a docstring — unaffected.

Full suite python -m pytest tests/ -q -p no:cacheprovider: 1323 passed (perf-tracker class went 5 yfinance tests → 7 daily-closes tests, net +2 vs the 1321 baseline), 1 pre-existing acceptable failuretests/test_scoring.py::TestRSIScoring::test_bull_overbought_matches_neutral_post_revert (stale-local-config; passes on CI). Zero new failures.

Combined-arc verification

On origin/main the only runtime yfinance sites are exactly R1/R2/R3/R4/R5 + local/time_scanner.py. PR1 (R1+R2+R4) + PR2 (R3) + PR3 (R5) remove every runtime site; local/time_scanner.py is dev-only and plan-excluded. Post PR1+2+3: zero live yfinance call sites in research runtime.

Deferred

None. Independent of PR1 and PR2 (off origin/main).


DEPLOY HELD — research auto-deploys on merge; do not merge until user directs. Part of the yfinance-centralization arc (plan doc alpha-engine-docs/private/yfinance-centralization-260516.md); intended to land before the held Research re-run.

🤖 Generated with Claude Code

cipher813 and others added 2 commits May 16, 2026 18:08
… (R5)

yfinance-centralization arc (plan: alpha-engine-docs/private/yfinance-centralization-260516.md),
PR 3 — R5. With PR1+PR2 this makes alpha-engine-research yfinance-free at
runtime (only local/time_scanner.py keeps yfinance — explicitly excluded by
the plan as a dev-only scanner not in the Lambda/SF path).

scoring/performance_tracker.py::run_performance_checks — replaced the
`yf.download(period="2d")` FALLBACK leg with the in-repo
data/fetchers/feature_store_reader.py::read_latest_daily_closes()
(alpha-engine-data's staging/daily_closes/ parquet → {ticker: close}).
Deleted `import yfinance as yf` + `import pandas as pd` (pandas was only
used by the removed yfinance multi-ticker DataFrame parsing); updated the
module docstring.

Polygon grouped-daily stays the PRIMARY path — completely unchanged. Only
the fallback leg swapped. The new get_latest_price() returns
polygon_prices[t] first, then daily_closes.get(t) — exact same precedence
as before (polygon, then fallback).

Graceful-degrade preserved (all-agents-strict, #195):
- read_latest_daily_closes() returns {ticker: close} or None and NEVER
  raises (broad except → None), strictly matching the old try/except
  contract — no read that degraded before now raises.
- If both polygon and the fallback yield nothing, the function returns
  _compute_accuracy_stats() with no new evaluations recorded — identical
  net behavior to the old yfinance-failed branch (which proceeded with
  price_data=None and recorded nothing).
- Missing-ticker → row skipped (current_price None), unchanged.

Tests: reworked tests/test_performance_tracker.py — the 5 tests that
patched `scoring.performance_tracker.yf.download` would break (yf removed),
so rewrote them to fake feature_store_reader.read_latest_daily_closes via
`monkeypatch` (NOT unittest.mock.patch — documented full-suite bleed;
mirrors tests/test_held_thesis_strict.py). Replaced the brittle
`@patch("...yf.download")` shape; removed the now-unused yf-shaped
`_mock_price_data` + pandas import. Added: module-is-yfinance-free
assertion, daily_closes-fallback 10d/beat-SPY/missing-ticker evals,
graceful-degrade-when-fallback-unavailable, and an explicit
polygon-primary-path-unaffected test with a tripwire that fails if the
fallback reader is called when polygon covers all tickers. test_archive.py
only references performance_tracker in a docstring — unaffected.
Full suite: 1323 passed (perf-tracker class 5 yfinance tests → 7
daily-closes tests; net +2 vs the 1321 baseline), 1 pre-existing
acceptable failure
(tests/test_scoring.py::TestRSIScoring::test_bull_overbought_matches_neutral_post_revert
— stale-local-config, passes on CI). Zero new failures.

**DEPLOY HELD — research auto-deploys on merge; do not merge until user
directs. Part of the yfinance-centralization arc (plan doc
alpha-engine-docs/private/yfinance-centralization-260516.md); intended to
land before the held Research re-run.**

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cipher813 cipher813 merged commit dd21357 into main May 17, 2026
1 check passed
@cipher813 cipher813 deleted the fix/yf-pr3-perftracker branch May 17, 2026 01:44
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