Bar indices that open a new trading session, read back from the timestamps.
An exchange's overnight break is the widest recurring gap in an intraday
series, and it is the only thing in the bars themselves that says where one
trading day ends. Reading it back beats assuming a timezone: the same code
has to serve an exchange in Mumbai and one in New York, and a fixed midnight
lands mid-session for one of them. Getting it wrong splices the tail of one
session onto the head of the next across the overnight gap, which inflates
that period's high-low range and throws anything measured from it a long way
off.
Returns null when the series shows no readable session break: a market that
never closes, bars already a day or coarser, or a feed whose only gaps are
weekends. The caller then falls back to a calendar rule, which is the right
answer in exactly those cases.
Bar indices that open a new trading session, read back from the timestamps.
An exchange's overnight break is the widest recurring gap in an intraday series, and it is the only thing in the bars themselves that says where one trading day ends. Reading it back beats assuming a timezone: the same code has to serve an exchange in Mumbai and one in New York, and a fixed midnight lands mid-session for one of them. Getting it wrong splices the tail of one session onto the head of the next across the overnight gap, which inflates that period's high-low range and throws anything measured from it a long way off.
Returns null when the series shows no readable session break: a market that never closes, bars already a day or coarser, or a feed whose only gaps are weekends. The caller then falls back to a calendar rule, which is the right answer in exactly those cases.