Exchange Calendars and Trading Sessions
Why 'the market is open' is a question every exchange answers differently, and how a hardcoded calendar quietly corrupts backtests around holidays and half-days.
A backtest that assumes "the market is open every weekday from 9:30 to 4:00" will run without complaint on Thanksgiving, on the day after a hurricane closes the NYSE, and on the half-day before Christmas that ends at 1:00 PM. Nothing crashes. The code computes a full day's worth of returns on a day that had two and a half hours of trading, or none at all, and a strategy that trades the close will "trade" a close price that was actually stale from the previous session. An exchange calendar is the lookup table that says, for any given date, whether the market is open, what hours it's open, and whether it's a shortened session — and skipping it is one of the most common sources of quietly wrong backtests.
Each exchange publishes its own calendar, and they don't agree with each other. The NYSE and Nasdaq share US holidays but not always the same early-close schedule as a bond market or a commodities exchange trading similar hours. A strategy running across US equities and European futures has to reconcile two independent holiday calendars, and days exist where one market trades and the other doesn't — Boxing Day closes London but not New York. Code that assumes a single shared calendar for a multi-market strategy will misalign exactly on the days that matter most for testing tail risk, since holidays cluster around thin-liquidity, headline-driven periods.
Sessions add a second layer beyond "open or closed." Many markets have a pre-market session, a regular session, and an after-hours session, each with different liquidity and different rules — a limit order resting pre-market may not be visible to the regular-session order book. Futures markets often trade nearly 24 hours with a short daily maintenance break. A pipeline that treats all timestamps inside a calendar day as equally "the market" will blend regular-session prices with thin after-hours prices that behave completely differently, distorting volatility and correlation estimates.
Worked example: a half-day that isn't marked
A backtest computes daily return as close price minus previous close price, using a hardcoded 4:00 PM close for every session. On the day before Independence Day, the actual close is at 1:00 PM. The pipeline pulls the price recorded at 4:00 PM in the raw feed anyway — which, on a half day, is simply the last quote before the market shut at 1:00, carried forward and stale for three hours. If a news event moves the market between 1:00 and 4:00 on that day, the backtest's "close" silently misses it, understating that day's volatility and making any close-to-close signal computed around it wrong for reasons invisible in the code.
What this means in practice
Any pipeline that computes daily bars, close-to-close returns, or session-relative features should look up the actual session boundaries for that exact date and exchange from a maintained calendar library, not assume a fixed schedule. This matters most in backtests, where a wrong calendar produces plausible-looking results, and least visibly in live trading, where an actual holiday closure is at least obvious to a human watching the screen.
An exchange calendar is not a convenience feature — it's the ground truth for whether a given date's data represents a full session, a shortened session, or no session at all, and every pipeline computing daily returns or close prices depends on getting it right.
Related concepts
Practice in interviews
Further reading
- Skiena, The Data Science Design Manual (data cleaning chapter)