Check Trading Holidays using exchange_calendars in python
How to check stock market trading holidays using the exchange_calendars library in Python.
March 3, 2026
Check Trading Holidays using exchange_calendars in python
When dealing with automated stock trading systems or financial data, checking whether the market is open is very important.
exchange_calendars library allows you to easily manage the holidays of major exchanges worldwide, including the Korea Exchange (KRX).1. Install Library
First, you need to install the necessary libraries.
Install commandbash
2. Check KRX Trading Holiday
This is code to retrieve the calendar for the Korea Exchange (XKRX) and check if today is a
session (business day).Trading Holiday Check Scriptpython
3. Key Concepts
- XKRX: This is the ISO code for the Korea Exchange. The US uses
XNYS(New York Stock Exchange),XNAS(NASDAQ), etc. - is_session(): Returns a
Booleanvalue indicating whether a specific date is a trading day (open day). It includes both weekends and holidays.
4. More Tips
If you want to get a list of all holidays within a specific period, you can automate scheduling using the
holidays_at attribute or the sessions_in_range method.