Market Calendars Made Easy with Python's Power.

Getting Market Calendars for trading.

For everyday activities of Business and Financial analysis it is very handy to have a quick way of getting information about markets trading availability i.e. their open and close times and holiday schedule. The script below will make use of free to use Python package pandas-market-calendars which provides access to over 50+ unique exchange calendars for global equity and futures markets and is widely used in finance and specifically for time series analysis.

market calendar.
Market Calendar meme.

Python Knowledge Base: Make coding great again.
- Updated: 2024-07-23 by Andrey BRATUS, Senior Data Analyst.

Now you will get all the information on holidays, late open and early close calendars for specific exchanges and OTC conventions. As seen in a simple program below, first you will display information on all available trading calendars, select and specify the one you interested in, fill the time period and enjoy the results !!!

Python code to extract Market Calendars names:

# pip install pandas_market_calendars
import pandas_market_calendars as mcal

# Show available calendars

Market Calendars names extraction output:

['ASX', 'BMF', 'CFE', 'CBOE_Futures', 'CBOE_Equity_Options', 'CBOE_Index_Options', 'CME_Equity', 'CBOT_Equity', 'CME_Agriculture', 'CBOT_Agriculture', 'COMEX_Agriculture', 'NYMEX_Agriculture', 'CME_Rate', 'CBOT_Rate', 'CME_InterestRate', 'CBOT_InterestRate', 'CME_Bond', 'CBOT_Bond', 'EUREX', 'HKEX', 'ICE', 'ICEUS', 'NYFE', 'NYSE', 'stock', 'NASDAQ', 'BATS', 'DJIA', 'DOW', 'IEX', 'Investors_Exchange', 'JPX', 'LSE', 'OSE', 'SIFMAUS', 'SIFMA_US', 'Capital_Markets_US', 'Financial_Markets_US', 'Bond_Markets_US', 'SIFMAUK', 'SIFMA_UK', 'Capital_Markets_UK', 'Financial_Markets_UK', 'Bond_Markets_UK', 'SIFMAJP', 'SIFMA_JP', 'Capital_Markets_JP', 'Financial_Markets_JP', 'Bond_Markets_JP', 'SIX', 'SSE', 'TSX', 'TSXV', 'BSE', 'NSE', 'TASE', 'AIXK', 'ASEX', 'BVMF', 'CMES', 'IEPA', 'XAMS', 'XASX', 'XBKK', 'XBOG', 'XBOM', 'XBRU', 'XBSE', 'XBUD', 'XBUE', 'XCBF', 'XCSE', 'XDUB', 'XFRA', 'XETR', 'XHEL', 'XHKG', 'XICE', 'XIDX', 'XIST', 'XJSE', 'XKAR', 'XKLS', 'XKRX', 'XLIM', 'XLIS', 'XLON', 'XMAD', 'XMEX', 'XMIL', 'XMOS', 'XNYS', 'XNZE', 'XOSL', 'XPAR', 'XPHS', 'XPRA', 'XSES', 'XSGO', 'XSHG', 'XSTO', 'XSWX', 'XTAE', 'XTAI', 'XTKS', 'XTSE', 'XWAR', 'XWBO', 'us_futures', '24/7', '24/5']

Python code to extract selected Market Calendar:

import pandas_market_calendars as mcal

# Create a calendar
myCalendar = mcal.get_calendar('NASDAQ')

marketschedule = myCalendar.schedule(start_date='2022-09-20', end_date='2022-09-27')

Market Calendar output:

Market Calendar output.

See also related topics: