Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions yfinance/scrapers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,15 +546,12 @@ def _get_history_cache(self, period="max", interval="1d", repair=False) -> pd.Da
return self._history_cache[cache_key]

def get_history_metadata(self) -> dict:
if self._history_metadata is None or 'tradingPeriods' not in self._history_metadata:
# Request intraday data, because then Yahoo returns exchange schedule (tradingPeriods).
if self._history_metadata is None or 'tradingPeriods' not in self._history_metadata:
# Request intraday data, because then Yahoo returns exchange schedule (tradingPeriods).
try:
self._get_history_cache(period="5d", interval="1h")['prices']

if self._history_metadata_formatted is False:
Comment thread
Gaze31 marked this conversation as resolved.
Resolved
self._history_metadata = utils.format_history_metadata(self._history_metadata)
self._history_metadata_formatted = True

return self._history_metadata
except Exception:
pass # tradingPeriods is optional enrichment; don't fail if intraday unavailable

def get_dividends(self, period="max", repair=False) -> pd.Series:
return self._get_history_cache(interval='1d', period=period, repair=repair)['dividends']
Expand Down