| name | calendar |
| description | Use whenever a strategy depends on the market calendar — market closures/holidays, trading-day counting, the Nth trading day before/after a date, or whether a date is a trading day. Use QuantConnect's built-in calendar; do not hand-roll a holiday calendar or hardcode dates. |
Market calendar — use QC's built-in calendar, don't reinvent it
Don't hand-roll a trading-day loop or hardcode dates. QuantConnect exposes the real historical calendar for each security's exchange. But it does NOT hand you a clean "named holidays" list, so read this carefully — the obvious-looking APIs do something different from what their names suggest (all behaviour below is verified on the cloud).
Stepping / counting trading days — THIS is the reliable primitive
On the exchange hours object:
hours = self.securities[symbol].exchange.hours
prev = hours.get_previous_trading_day(d)
nxt = hours.get_next_trading_day(d)
open_today = hours.is_date_open(d)
These skip weekends and all closures, so no manual weekend/holiday checks are needed.
- "Last trading day before date H" →
hours.get_previous_trading_day(H).
- "Nth trading day before H" → start at H and call
get_previous_trading_day N times in a loop.
- Verified: before Memorial Day 2025 (Mon 5/26), one step → 5/23, five steps → 5/19;
is_date_open(5/26) → False.
The session open/close TIME on a date (early-close aware)
For the actual TIME the exchange opens/closes on a date — not just whether it trades — use the exchange-hours helpers, instead of reading or hand-rolling the session segments: