You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
get_history_metadata() raises YFPricesMissingError for valid tickers when intraday data is unavailable #2745
get_history_metadata() can raise YFPricesMissingError for valid, non-delisted tickers (e.g., ROG.SW) even after history() succeeds.
The method forces a second request (period="5d", interval="1h") to populate tradingPeriods in the metadata. For some tickers/exchanges, this intraday request returns no price data and raises YFPricesMissingError. The metadata — including currency, exchangeName, timezone, etc. — was already populated by the prior history() call, but the method refuses to return it.
Worse, the failing request can overwrite the already-populated _history_metadata with {} (line 224-225 of history.py), destroying cached metadata.
This is a regression from 0.2.x where get_history_metadata() returned whatever metadata was already cached without the tradingPeriods gate.
Related: #2344 fixed the inverse problem (metadata call corrupting history cache) but introduced this failure path.
defget_history_metadata(self) ->dict:
ifself._history_metadataisNoneor'tradingPeriods'notinself._history_metadata:
self._get_history_cache(period="5d", interval="1h") # <-- fails here
The or 'tradingPeriods' not in self._history_metadata clause forces a second intraday request even when metadata is already populated. If that request fails, the method raises instead of returning the metadata it already has.
Suggested fix
Two changes:
Don't let the tradingPeriods fetch break the getter:
I'd like to implement this fix. The suggested changes are clear — wrapping the tradingPeriods fetch in try/except and protecting the metadata cache from being overwritten on failure. I'll fork the repo and submit a PR. Can I be assigned?
I've submitted a fix for this in PR #2758. The change wraps the tradingPeriods intraday fetch in a try/except block so that YFPricesMissingError is caught gracefully and the already-cached metadata is returned instead of crashing.
Activity
fix: work around yfinance get_history_metadata() bug
Release 0.10.1 — Fix yfinance metadata bug
Gaze31 commentedon Apr 18, 2026
I'd like to implement this fix. The suggested changes are clear — wrapping the tradingPeriods fetch in try/except and protecting the metadata cache from being overwritten on failure. I'll fork the repo and submit a PR. Can I be assigned?
fix: handle YFPricesMissingError in get_history_metadata when intrada…
Gaze31 commentedon Apr 18, 2026
I've submitted a fix for this in PR #2758. The change wraps the tradingPeriods intraday fetch in a try/except block so that YFPricesMissingError is caught gracefully and the already-cached metadata is returned instead of crashing.
Fix get_history_metadata() raising YFPricesMissingError for valid tic…
ValueRaider commentedon Aug 24, 2026
I think #2922 is better way - will be in next release.