How to get an exchange trading calendar as data

Holidays, 1 p.m. early closes and session times as a table, from a library or an API — and why a calendar of trading days is not a calendar of settlement days.

Use exchange_calendars, a free Python library that returns every session for 69 exchanges with open and close times in UTC, early closes included; its New York calendar matched NYSE's published 2026 and 2027 holidays exactly. For a live service, Massive and EODHD return upcoming holidays and early closes from an API. What breaks is the closure nobody scheduled, and the settlement calendar, which is a different set of days.

The short way

exchange_calendars is a pip install and needs no key, because the calendars are package code rather than a feed:

import exchange_calendars as xcals

nyse = xcals.get_calendar("XNYS", start="2026-01-01", end="2027-12-31")

sched = nyse.schedule                      # one row per session, times in UTC
closes = sched["close"].dt.tz_convert("America/New_York")
early = closes[closes.dt.hour < 16]

print(len(sched), "sessions")
print(early.dt.strftime("%Y-%m-%d %H:%M %Z").tolist())
print(nyse.next_session("2026-07-02"))

On 4 October 2026, with version 4.13.2, that printed 502 sessions, early closes at 13:00 on 27 November 2026, 24 December 2026 and 26 November 2027, and 6 July 2026 as the session after 2 July. Every weekday it leaves out — ten in each year — is a holiday on NYSE's own published list for 2026 and 2027, and the three early closes are the three NYSE lists. is_session, sessions_in_range and trading_index do the rest: a range of trading days, a minute index with the closed hours removed, the question "was it open".

The calendar names are ISO 10383 market codes — XNYS, XLON, XTKS, CMES — and the schedule's open, break_start, break_end and close columns are timezone-aware UTC, so a Hong Kong lunch break and a Thanksgiving half-day are rows of data rather than special cases.

What the options are

A library, offline. exchange_calendars covers 69 exchanges and answers instantly, because nothing is fetched. pandas_market_calendars mirrors the same calendars under its own schedule() API, depends on this package, and adds futures calendars plus a native NYSE class that is separate code from the mirrored XNYS; on 4 October 2026 its version 5.4.0 returned the same three NYSE early closes. The cost of offline is that a correction reaches you by upgrading — and the last PyPI release was 10 March 2026, with later fixes only in git.

An API, upcoming only. Massive's /v1/marketstatus/upcoming returns the next holidays for NYSE, Nasdaq and OTC separately, each with a status of closed or early-close and, for a half-day, open and close as UTC timestamps. It is in every Stocks plan including the free one, and Massive documents it as forward-looking only: it will tell you about next Thanksgiving and not about last year's.

An API, worldwide. EODHD's v2 exchange-details endpoint covers 73 exchanges with the timezone, regular and extended session hours, lunch breaks and an ExchangeHolidays object keyed by date, each entry typed Official, Bank or EarlyClose, with the early close time on the last. It comes with the $29.99 EOD+Intraday plan and the All-In-One plan, not the $19.99 end-of-day plan, and each request costs 5 API calls.

Business days, for settlement. QuantLib answers a different question — is this a business day for this market — with 47 national calendars and the machinery to combine them. ql.UnitedStates(ql.UnitedStates.NYSE) is the trading calendar; ql.UnitedStates(ql.UnitedStates.Settlement) is a different one, and the difference is the subject of the last section below.

Where this breaks

Closures nobody scheduled. NYSE closed on 9 January 2025 for the national day of mourning for President Carter, and on 5 December 2018 for President George H. W. Bush. No rule generates those; exchange_calendars lists them as hand-entered dates in its source, which means a calendar computed before the announcement had them as ordinary sessions. Weather closures work the same way. A library is only as current as the version installed, and an API's upcoming list only as current as its last refresh — re-pull, and treat any cached calendar as provisional for the coming weeks.

The future runs out. exchange_calendars builds twenty years back and one year forward by default. On 4 October 2026, get_calendar("XNYS") ended on 4 October 2027, and asking about a date in 2028 raised DateOutOfBounds — so Thanksgiving 2027 is outside the default calendar today. Pass end= explicitly. Those future sessions are generated from rules, not read from an exchange notice, which is why they matched NYSE's list for 2026–2027 and why that match is worth rechecking each year.

A half-day is 1 p.m., and not for everything. NYSE's early closes are at 1:00 p.m. Eastern, but eligible options close at 1:15 p.m. and the late trading sessions of NYSE American, Arca, National and Texas run to 5:00 p.m. on the same day. A bar series that expects a 4 p.m. close will show the final three hours missing, and a job scheduled for 4:05 p.m. runs after a close that happened three hours earlier.

Options and futures keep their own calendars. An equity calendar is not a derivatives calendar. In exchange_calendars on 4 October 2026, XNYS and Cboe Futures' XCBF both treated Juneteenth 2026 as closed, while CMES, the CME calendar, treated it as a session. Use the calendar of the venue the instrument trades on, not the one its underlying trades on.

Time zones, twice a year. Session times are stored in UTC, and the NYSE open is 14:30 UTC in January and 13:30 UTC in July. Code that hard-codes the UTC open is an hour wrong for half the year; code that compares a naive local timestamp with a UTC schedule is wrong on the two Sunday mornings the clocks change, and the US and Europe change clocks on different weekends.

Trading days are not settlement days. The Federal Reserve closes on Columbus Day and Veterans Day — 12 October and 11 November in 2026 — and NYSE trades on both. Going the other way, NYSE shuts on Good Friday and on 3 July 2026, and the Federal Reserve Banks are open. In QuantLib 1.43, 12 October and 11 November 2026 are business days on the NYSE calendar and holidays on the Settlement calendar. Count settlement or payment dates in exchange sessions and they come out a day early around both, in most years; count them on a bank calendar and the Good Friday case goes wrong instead. Keep both, and say which one each date column is.

Early close is not a holiday flag. QuantLib knows whether a day is a business day and nothing about what time the market shut: 27 November 2026 is simply a business day. Massive and EODHD mark half-days explicitly; exchange_calendars puts the earlier close in the schedule. If the question is "how many hours of trading", only those three answer it.

If you outgrow this

You need intraday auctions or the reason for a closure. exchange_calendars gives open and closed, not why, and models only the regular session, so pre-market and auctions read as closed. EODHD's v2 response carries pre-market and after-hours times for US exchanges; anything finer is the exchange's own notice.

You need the calendar to agree with your bars. Then take both from the same vendor, or generate your expected sessions from the calendar and diff them against the bars you have — a missing day is either a holiday or a gap, and only the calendar can tell you which. Backfilling minute bars is where that check pays for itself.

The rest of the field is in analysis libraries and market data APIs.

The tools that do this

In the order this page recommends trying them. Paid placement does not affect this order.

  1. exchange_calendars

    Every session, early close and lunch break for 69 exchanges as a DataFrame, offline. Free; a new closure reaches you only by upgrading.

    Sessions, minutes and holidays for 69 exchanges, keyed by ISO-10383 code.

    FreeFree tierOpen source

  2. Massive

    Upcoming US holidays and early closes per exchange, with open and close times, on every plan including the free one. Forward-looking only.

    Full-tick US equities, options and futures from a direct exchange feed.

    $29/moFree tier

  3. EODHD

    Holidays, early closes and session hours for 73 exchanges, typed official, bank or early close. From the $29.99 plan, at 5 calls a request.

    End-of-day and fundamentals for 60+ exchanges worldwide, at a hobbyist price.

    $19.99/moFree tier

  4. QuantLib

    Business-day calendars for 47 countries, including a US settlement calendar that is not the NYSE one. Knows open or shut, never what time.

    The open-source derivatives pricing library banks actually use, reachable from Python.

    FreeFree tierOpen source

FAQ

When is the NYSE closed in 2026 and 2027?

In 2026 on 1 January, 19 January, 16 February, 3 April, 25 May, 19 June, 3 July, 7 September, 26 November and 25 December, closing at 1 p.m. on 27 November and 24 December. In 2027 on 1 January, 18 January, 15 February, 26 March, 31 May, 18 June, 5 July, 6 September, 25 November and 24 December, closing early only on 26 November. That is NYSE's own list as published on 4 October 2026.

Is pandas_market_calendars better than exchange_calendars?

It is a layer on top of it rather than a rival. pandas_market_calendars, by a different author under the MIT licence, depends on exchange_calendars and adds its own schedule and date-range API plus some futures conventions. On 4 October 2026 version 5.4.0 returned the same 2026–2027 NYSE early closes as exchange_calendars 4.13.2. Its own NYSE calendar is separate code, though; XNYS inside it is the exchange_calendars mirror. On 4 October 2026 the two returned the same 5,281 sessions from 4 October 2006 to 4 October 2027, but a fix to one does not reach the other. Pick by API, then use one name consistently.

Why is there no New Year's Day holiday in 2028?

Because 1 January 2028 is a Saturday, and NYSE's list says that in that case no New Year's Day holiday is observed — 2028 is marked with a dash, and Friday 31 December 2027 is an ordinary session. The Federal Reserve Board does close on 31 December 2027, while the Reserve Banks stay open. A rule that moves every Saturday holiday to Friday gets this one wrong.

Sources

  1. Holidays & Trading Hours — New York Stock Exchange, read
  2. Holidays Observed — K.8 — Board of Governors of the Federal Reserve System,
  3. Market Holidays — Stocks REST API — Massive, read
  4. Stock Market Trading Hours and Holidays API — EODHD,
  5. exchange_calendars — us_holidays.py — exchange_calendars project, read

The catalogue next door

This page names a handful of cards. The rest of them are in Market Analysis & Portfolio Optimization Libraries, each filled in against the same schema, with the fields to narrow it yourself.

Last updated . Corrected in place: this is a reference page, not a dated post.