[codex] Refactor Yahoo support to use direct yfinance#2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5835be8669
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "start": args.start, | ||
| "end": args.end, |
There was a problem hiding this comment.
Normalize relative dates before building history cache keys
history_cache_path hashes the raw args.start/args.end strings, but --end defaults to today; with --cache-dir, runs on different days can reuse the exact same cache file when the same relative tokens are passed. For example, a job run on April 5 and rerun on April 6 with --end today will read stale data instead of fetching the new bar, silently freezing incremental history updates.
Useful? React with 👍 / 👎.
| if cache_path is not None and cache_path.exists(): | ||
| rows = json.loads(cache_path.read_text(encoding="utf-8")) | ||
| if isinstance(rows, list): | ||
| return build_snapshot_frame([row for row in rows if isinstance(row, dict)]) |
There was a problem hiding this comment.
Add freshness to current snapshot cache lookup
When a snapshot cache file exists, the function returns it immediately and skips all Yahoo calls, and the cache key is only ticker-based. In any workflow that enables --cache-dir, current_snapshot stops being current after the first run and stays stale until the file is manually removed, which undermines the dataset’s purpose for live quote/fundamental checks.
Useful? React with 👍 / 👎.
Summary
yf_marketdatawrapper with direct Yahoo Finance support viayfinancescripts/fetch_yfinance.pyforhistoryandcurrent_snapshotWhy
The previous Yahoo path depended on an external helper repo and a YAML config flow that was heavier than the rest of aMDT. This change keeps Yahoo support inside the repo, aligns it with the other provider helpers, and preserves the useful retry, cache, and wide snapshot behavior.
What changed
scripts/fetch_yfinance.pywith CLI-based dataset selection and export controlsscripts/run_yf_marketdata.pyassets/yf_marketdata.template.yamlyfinanceValidation
python -m py_compileacrossscripts/*.pyyf_marketdatareferences remain in the repoSPYSPYandTLTcurrent_snapshotfor^VIXandSPYNotes
Yahoo returned some expected 404-style fundamentals warnings during snapshot fetches for
SPYand^VIX, but the exports completed successfully and the script degraded gracefully.