How do you check for market holidays (any modules)?

I've written my own calendar generation software that's pretty reliable. I can send you the text file I generate that contains all historical dates if that's helpful? Something else to be aware of is that there are half days that occur near thanksgiving and Christmas where the exchange closes at 1:00pm. These are documented on the NYSE and Nasdaq websites.
 
Can vouch for pandas market calendars I use it extensively. Just install the module using pip and set it to NYSE for american markets. An example function i wrote:
```
def_get_next_trading_day(self, date: datetime) -> datetime:
'''
Takes a date and returns the next trading day using pandas_market_calendars

param date: datetime object

:return: datetime object of the next trading day
'''
nyse = mcal.get_calendar('NYSE')
schedule = nyse.schedule(start_date=date, end_date=date + pd.Timedelta(days=10))
next_trading_day = schedule[schedule.index > date].index[0]
returnnext_trading_day​
```

Yeah I've PR'd it a long time ago as well.
 
I've written my own calendar generation software that's pretty reliable. I can send you the text file I generate that contains all historical dates if that's helpful? Something else to be aware of is that there are half days that occur near thanksgiving and Christmas where the exchange closes at 1:00pm. These are documented on the NYSE and Nasdaq websites.

Can I ask why? The one's mentioned here already handle regular holidays, irregular ones, half-days, different markets and timezones.
 
Can I ask why? The one's mentioned here already handle regular holidays, irregular ones, half-days, different markets and timezones.

I wrote this several years ago, in C# not Python. It's working so no reason to change it.
 
There's no simple way to do it, as someone said here, if you got historical market data from somewhere then if it's got no data for some day, most likely it's a holiday. Unfortunately often times it's just shitty, missing data, so you gotta do some statistics, using multiple stocks (hopefully on the same market / exchange), if they ALL miss that day then it's definitely a market holiday.
 
Back
Top