Skip to content

fix: handle YFPricesMissingError in get_history_metadata when intraday data unavailable - #2758

Open
Gaze31 wants to merge 4 commits into
ranaroussi:mainfrom
Gaze31:fix/get-history-metadata-trading-periods-error
Open

Gaze31 wants to merge 4 commits into
ranaroussi:mainfrom
Gaze31:fix/get-history-metadata-trading-periods-error

Conversation

@Gaze31

@Gaze31 Gaze31 commented Apr 18, 2026

Copy link
Copy Markdown

Fixes #2745

Problem

get_history_metadata() raises YFPricesMissingError for valid,
non-delisted tickers when intraday data is unavailable, even after
history() succeeds. The tradingPeriods fetch was crashing the
entire method instead of gracefully continuing.

Fix

Wrapped the intraday cache call in a try/except block so that
YFPricesMissingError is caught and ignored. The tradingPeriods
field is optional enrichment — its absence should not prevent
returning already-cached metadata.

Testing

Tested with ROG.SW ticker as described in the issue report.

Comment thread yfinance/scrapers/history.py Resolved
@ValueRaider

Copy link
Copy Markdown
Collaborator

Look at the diff. Also rebase to dev branch https://ranaroussi.github.io/yfinance/development/code.html

@Gaze31

Gaze31 commented Apr 18, 2026

Copy link
Copy Markdown
Author

Apologies for the unintentional removal. I have restored the blank line between the try/except block and the metadata formatting check. The fix is pushed to the same branch.

@ValueRaider

ValueRaider commented Apr 18, 2026 •

Copy link
Copy Markdown
Collaborator

Ok you aren't checking diff.

@Gaze31 Gaze31 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies — that was an unintentional removal. The blank line has been restored in the latest commit.

Comment thread yfinance/scrapers/history.py Resolved
@Gaze31

Gaze31 commented Apr 19, 2026

Copy link
Copy Markdown
Author

Ok you aren't checking diff.

Apologies — I accidentally introduced a nested function definition. Fixed now and pushed to the same branch.

@Gaze31

Gaze31 commented Apr 19, 2026

Copy link
Copy Markdown
Author

Fixed — removed the duplicate function definition and cleaned up indentation. The try/except now correctly wraps only the intraday cache call.

@ValueRaider

ValueRaider commented Apr 19, 2026 •

Copy link
Copy Markdown
Collaborator

rebase to dev branch https://ranaroussi.github.io/yfinance/development/code.html

then git squash

@ValueRaider ValueRaider reopened this Apr 19, 2026

This branch has not been deployed

No deployments
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.

get_history_metadata() raises YFPricesMissingError for valid tickers when intraday data is unavailable

2 participants