Skip to content

Commit

Permalink
solves #2026
Browse files Browse the repository at this point in the history
Solution that checks the offset of the opening time of the stock exchange (mod 30 minutes) and adds it to the quotes
  • Loading branch information
aleksfasting committed Aug 15, 2024
1 parent 2b8716c commit 1037ec5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion yfinance/scrapers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ def history(self, period="1mo", interval="1d",
# 2) fix weired bug with Yahoo! - returning 60m for 30m bars
if interval.lower() == "30m":
logger.debug(f'{self.ticker}: resampling 30m OHLC from 15m')
quotes2 = quotes.resample('30min')
exchangeStartTime = pd.Timestamp(self._history_metadata["tradingPeriods"][0][0]["start"], unit='s')
offset = str(exchangeStartTime.minute % 30)+"min"
quotes2 = quotes.resample('30min', offset=offset)
quotes = pd.DataFrame(index=quotes2.last().index, data={
'Open': quotes2['Open'].first(),
'High': quotes2['High'].max(),
Expand Down

0 comments on commit 1037ec5

Please sign in to comment.