Skip to content

Exchange Calendar

market-feed/calendar provides synchronous, offline-capable exchange session and holiday detection. No network calls, no async — works on the edge.

Supported exchanges

ExchangeIDTimezoneHours
New York Stock ExchangeNYSEAmerica/New_York09:30–16:00
NASDAQNASDAQAmerica/New_York09:30–16:00
London Stock ExchangeLSEEurope/London08:00–16:30
Toronto Stock ExchangeTSXAmerica/Toronto09:30–16:00
Australian Securities ExchangeASXAustralia/Sydney10:00–16:00
Frankfurt (XETRA)XETRAEurope/Berlin09:00–17:30
National Stock Exchange IndiaNSEAsia/Kolkata09:15–15:30
Bombay Stock ExchangeBSEAsia/Kolkata09:15–15:30
CryptoCRYPTOUTC24/7 (no sessions, no holidays)

Session check

ts
import { isMarketOpen, getSession } from "market-feed/calendar";

isMarketOpen("NYSE");  // true | false

getSession("NYSE");    // "pre" | "regular" | "post" | "closed"

Sessions:

ValueNYSE hours (ET)
"pre"04:00–09:30
"regular"09:30–16:00
"post"16:00–20:00
"closed"outside all of the above

Next open / close

ts
import { nextSessionOpen, nextSessionClose } from "market-feed/calendar";

nextSessionOpen("NYSE");   // Date — next regular session open (UTC)
nextSessionClose("NYSE");  // Date — next regular session close (UTC)

Both functions skip holidays and weekends, and are DST-correct via Intl.DateTimeFormat.

Holidays

ts
import { isHoliday, isEarlyClose, getHolidayDates } from "market-feed/calendar";

isHoliday("NYSE");                           // is today a NYSE holiday?
isHoliday("NYSE", new Date("2025-04-18"));   // true — Good Friday 2025
isHoliday("LSE", new Date("2025-12-26"));    // true — Boxing Day

isEarlyClose("NYSE");                        // true on day before Thanksgiving, Christmas Eve

getHolidayDates("NYSE", 2026);              // Date[] — all NYSE holidays in 2026

Holiday rules are computed from first principles — Easter via the Meeus/Jones/Butcher algorithm, followed by all NYSE-specific adjustments. No hardcoded date arrays.

Exchange metadata

ts
import { getExchangeInfo } from "market-feed/calendar";

const info = getExchangeInfo("LSE");
// {
//   id: "LSE",
//   name: "London Stock Exchange",
//   mic: "XLON",
//   timezone: "Europe/London",
//   openTime: "08:00",
//   closeTime: "16:30",
//   currency: "GBP",
// }

Usage with market-feed/stream

The stream module uses the calendar internally when marketHoursAware: true. Pass exchange to select the right calendar:

ts
import { watch } from "market-feed/stream";

for await (const event of watch(feed, ["TSLA"], { exchange: "NYSE" })) {
  // pauses when NYSE is closed
}

Released under the MIT License.