Exchange Calendars

4.13.2 · active · verified Fri Apr 10

exchange-calendars is a Python library designed for defining and querying calendars for various securities exchanges, providing out-of-the-box support for over 50 global exchanges. It is an actively maintained fork of the original `trading_calendars` package. The library is currently at version 4.13.2 and receives frequent updates, primarily to add and correct holiday schedules and trading hours for exchanges worldwide.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the library, list available calendars, retrieve a specific exchange calendar (NYSE in this case), and query its trading schedule for a given date range.

import exchange_calendars as xcals
import pandas as pd

# Get a list of available calendar names
print("Available calendars (first 5):", xcals.get_calendar_names(include_aliases=False)[:5])

# Get the New York Stock Exchange (XNYS) calendar
xnys = xcals.get_calendar("XNYS")

# Query the schedule for a specific date range
start_date = pd.Timestamp("2023-12-28", tz='UTC')
end_date = pd.Timestamp("2024-01-03", tz='UTC')
schedule = xnys.schedule.loc[start_date:end_date]

print("\nNYSE Schedule (2023-12-28 to 2024-01-03):")
print(schedule)

view raw JSON →