Repository navigation
Return an empty frame when Yahoo has no session in the requested window - #166
Merged
Merged
Conversation
A ranged Yahoo download for a known symbol over a weekend or exchange holiday raised SymbolNotFoundError, so callers could not tell an empty window from an unknown symbol. The other providers return the canonical empty frame for an empty range, and StorageManager.update and the loaders already test is_empty(). yfinance reports the two cases differently: an unknown symbol fails with YFTzMissingError, a known symbol without bars in the window with YFPricesMissingError. Delisted symbols also raise the latter, so after an empty download the provider asks for the last month of daily bars and only returns an empty frame when Yahoo has recent sessions for the symbol. fetch_adjusted_close returns an empty typed frame the same way, and a placeholder-only response (the current session's null-price row) is now an empty window instead of a missing symbol. Closes #164
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.
Closes #164
What changes
A ranged Yahoo download for a known symbol over a window without a session (a weekend, an exchange holiday) now returns the canonical empty OHLCV frame, as the other providers do and as
StorageManager.updateand the loaders expect (is_empty()).SymbolNotFoundErroris kept for a symbol Yahoo does not know or has no recent sessions for.yfinance 1.5.2 reports the two cases differently: an unknown symbol fails with
YFTzMissingError, a known symbol without bars in the window withYFPricesMissingError. Delisted symbols also produce the latter, so after an empty download the provider requests the last month of daily bars once and returns an empty frame only when Yahoo has recent sessions. A rate limit during that request is aRateLimitError, not a missing symbol.fetch_ohlcv: empty session window -> empty canonical frame. A response holding only the current session's null-price placeholder row is the same case.fetch_adjusted_close: empty typed frame (timestamp,symbol,close) with provenance metadata set.docs/providers/yahoo.mddocuments the distinction.tests/test_yahoo_provider.py::test_a_response_of_nothing_but_placeholders_is_not_dataasserted the old behaviour (SymbolNotFoundErrorfor a placeholder-only response from AAPL). It is now..._is_an_empty_windowand asserts the empty canonical frame.Tests
Each test names the error it prevents. Run against origin/main (a367050) and this branch:
test_a_weekend_returns_the_canonical_empty_frametest_a_window_holding_only_the_current_session_placeholder_is_emptytest_adjusted_close_over_a_weekend_returns_an_empty_typed_frametest_a_rate_limit_while_confirming_the_symbol_is_a_rate_limittest_a_response_of_nothing_but_placeholders_is_an_empty_windowtest_an_unknown_symbol_over_a_weekend_is_still_not_found(guard)test_a_symbol_without_recent_prices_is_still_not_found(guard)The guards fail on an over-broad fix (treating every
YFPricesMissingErroras empty without the recent-session check); checked by mutation. Integration testtest_window_without_sessions_is_empty_not_unknown(live,-m integration) passes.Live check against Yahoo
origin/main: SPY over 2025-06-07..08, SPY on 2025-12-25 and
fetch_adjusted_closeover the weekend all raisedSymbolNotFoundError.This branch:
Not changed
fetch_batch_ohlcvis untouched.YFPricesMissingErrorcaused by a transient HTTP error, followed by a successful recent-session request, now yields an empty frame rather than an error.Gates
ruff check,ruff format --check,ty check,pytest testswith coverage (4650 passed, 1 skipped), the-W error::ResourceWarninglane (4650 passed),mkdocs build --strict,uv build,actionlint,pre-commit run --all-files: all pass. No pre-existing failures.