fix(research): [PR3] perf-tracker yfinance fallback → daily_closes S3 (R5)#199
Merged
Conversation
… (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>
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.
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 islocal/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 theyf.download(period="2d")fallback leg with the in-repodata/fetchers/feature_store_reader.py::read_latest_daily_closes()(alpha-engine-data'sstaging/daily_closes/parquet →{ticker: close}). Deletedimport 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()returnspolygon_prices[t]first, thendaily_closes.get(t)— identical precedence to before.Graceful-degrade preserved (all-agents-strict, #195)
read_latest_daily_closes()returns{ticker: close}orNoneand never raises (broad except → None) — strictly matches the old try/except contract. No read that degraded before now raises._compute_accuracy_stats()with no new evaluations recorded — identical net behavior to the old yfinance-failed branch (which proceeded withprice_data=Noneand recorded nothing).Tests
Reworked
tests/test_performance_tracker.py: the 5 tests that patchedscoring.performance_tracker.yf.downloadwould break (yf removed), so rewrote them to fakefeature_store_reader.read_latest_daily_closesviamonkeypatch(NOTunittest.mock.patch— documented full-suite bleed; mirrorstests/test_held_thesis_strict.py). Removed the now-unused yf-shaped_mock_price_datahelper + 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.pyreferencesperformance_trackeronly 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 failure —tests/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/mainthe 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.pyis 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