Session-Aligned pandas OHLC Resampling: Handling Lunch Breaks and Empty Bars
Applying resample().ohlc() to minute data that follows a trading calendar produces many empty bars, misaligned hourly bars and incorrect daily candles. The article uses a synthetic per-minute heat score for one stock, with sessions running 09:30-11:30 and 13:00-15:00. Of 203 generated bars, 163 are empty because resample fills the lunch break, overnight gap and weekends, and the author recommends dropping them rather than forward-filling. Thirty-minute bars align with the sessions, while 60-minute bars anchored to midnight yield half-length bars unless an offset is applied. The example also shows that a simulated news burst on Wednesday appears clearly in the resampled bars.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in