Avoid redundant timezone request for range history - #2899
Open
JonArnfred wants to merge 1 commit into
Open
Conversation
Collaborator
|
Passing getter and setter as arguments is bad. Need refactor: move _get_ticker_tz and _fetch_ticker_tz into utils.py. Might be time to split-out some of utils.py into price_utils.py |
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.
Summary
exchangeTimezoneNamefrom the requested chart response and persist it in the timezone cache.period="max", and repair paths that require timezone-aware date conversion.curl_cffi.Why
On a cold timezone cache,
Ticker.history(period="...")currently initializesPriceHistoryby making a separaterange=1dchart request to discover the ticker timezone. The requested history call then makes another chart request whose metadata contains the same timezone.This means an ordinary range-based history call makes two chart requests when only one is necessary. The extra request increases latency and Yahoo request volume, particularly for bulk downloads of previously unseen tickers.
The one-request behavior was previously covered by #1215, and avoiding the separate timezone request was also discussed around #1076 and #1112.
Behavior
Range-based calls now obtain and cache the timezone from their own chart response:
Calls that need the exchange timezone before constructing request timestamps retain the existing lookup behavior:
There are no public API changes.
Testing