> ## Documentation Index
> Fetch the complete documentation index at: https://knowledge.cloudquant.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Market Calendar (mcal) to Identify Trading Dates

> Programmatically determine trading dates using the pandas_market_calendars library for NYSE, CME, CBOE, NASDAQ, and other exchanges.

# Using Market Calendar (mcal) to identify trading dates

When retrieving market data, it is beneficial to programmatically determine which dates represent actual trading dates. The **Market Calendar (mcal)** library enables this functionality.

## US stock market calendars

Market Calendar supports multiple US exchanges including NYSE, CME, CBOE, and NASDAQ.

## Implementation example

```python theme={null}
# Get NYSE Schedule for date range
# Documentation: https://pandas-market-calendars.readthedocs.io/en/latest/usage.html

start_date = '2024-01-01'
end_date = '2024-06-01'

import pandas as pd
import pandas_market_calendars as mcal

nyse = mcal.get_calendar('NYSE')
schedule = nyse.schedule(start_date=start_date, end_date=end_date)
schedule

schedule.market_open.iloc[0]   # open time first date
schedule.market_close.iloc[0]  # close time first date
schedule.market_open.iloc[-1]  # open time last date
schedule.market_close.iloc[-1] # close time last date

schedlist = list(schedule.index)
schedlist
```

<Warning>
  Although mcal is generally extremely reliable, it is an external library and has on occasion missed a market holiday. Implement defensive coding practices and verify results independently.
</Warning>

The library demonstrates strong reliability for US market holidays but cannot be vouched for with equal confidence regarding international markets.

## Resources

* [Official pandas\_market\_calendars Documentation](https://pandas-market-calendars.readthedocs.io/en/latest/usage.html)
