Skip to content

Commit

Permalink
Merge pull request #1970 from ranaroussi/fix/history-metadata
Browse files Browse the repository at this point in the history
history metadata: Fix '1wk is invalid' & repeated calls
  • Loading branch information
ValueRaider authored Jun 28, 2024
2 parents 2d5978e + a9f6c33 commit 6be7cc3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion yfinance/scrapers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def history(self, period="1mo", interval="1d",
tps = self._history_metadata["tradingPeriods"]
if not isinstance(tps, pd.DataFrame):
self._history_metadata = utils.format_history_metadata(self._history_metadata, tradingPeriodsOnly=True)
self._history_metadata_formatted = True
tps = self._history_metadata["tradingPeriods"]
quotes = utils.fix_Yahoo_returning_prepost_unrequested(quotes, params["interval"], tps)
logger.debug(f'{self.ticker}: OHLC after cleaning: {quotes.index[0]} -> {quotes.index[-1]}')
Expand Down Expand Up @@ -391,7 +392,7 @@ def history(self, period="1mo", interval="1d",
def get_history_metadata(self, proxy=None) -> dict:
if self._history_metadata is None:
# Request intraday data, because then Yahoo returns exchange schedule.
self.history(period="1wk", interval="1h", prepost=True, proxy=proxy)
self.history(period="5d", interval="1h", prepost=True, proxy=proxy)

if self._history_metadata_formatted is False:
self._history_metadata = utils.format_history_metadata(self._history_metadata)
Expand Down

0 comments on commit 6be7cc3

Please sign in to comment.