Reliable stockmarket holiday, open and close time dataset/api?

Is there a reliable machine readable source of stock market holiday calendars?

I could scrape it, but honestly, I have my doubts about it staying well formatted and conforming over time, or even exist at all over time. Also it doesn't seem to have historic data, including abnormal close times like 9/11.

A good thing about it is that it includes special close times. Some markets close early on some days, notably Stockholm has a bunch of them.

• – rbm Apr 25 '17 at 12:52

pandas_market_calendars should do the job. I think there aren't any market calendars that feature 9/11 or the 2012 storm days as holidays.

• Thank you. Actually, the zipline library, which this package forks parts of, is what I started with. I've implemented a calendar for Oslo Stock Exchange (OSE) using pandas with the same principles. To be honest, I've come to the opinion that the approach taken here, i.e., programmatically calculating the calendar, is the wrong way to go. It is error prone, does not adjust to future events like 9/11, and is limited to direct use with python unless you export it (which I have). This is such a small dataset that a curated dataset from a data provider makes much more sense. – André Christoffer Andersen Apr 25 '17 at 16:24
• To its credit, though, it does include some past special events. E.g., September11Closings is a date range in the  us_holidays.py module used in exchange_calendar_nyse.py. – André Christoffer Andersen Apr 25 '17 at 16:26
• Calculating future holidays programmatically would be the right way to go as that ensures the code can run forever without interference. You can pipe out the holidays into any languages you choose, it's not strictly tied to Python. How can you adjust to a future 9/11 type event? – misantroop Apr 25 '17 at 20:23
• Not sure if curated or programmatic but this is the default web calendar I use. link – misantroop Apr 25 '17 at 20:27
• A curated dataset would be kept constantly updated through a daily load from the data provider’s API, into our systems. If any 9/11 event happens, or the exchanges schedule changes, say a new holiday, the providers would do an update and the changes would appear in our dataset the day after, if not immediately. With this package, changes from the preprogrammed schedule would not be captured. And if it were to be updated we would have to actually wait for, or in worst case contribute to, a software update, for something which should be a simple data update. – André Christoffer Andersen Apr 25 '17 at 20:55

The best most comprehensive (and therefore not free) calendar service I know of is at Swaps Monitor - sounds very fixed income-y, but they also have stock market calendar data. If you are doing something in a production environment, this is the sort of thing you want.

http://www.financialcalendar.com/Data/Holidays/Overview

• Thanks! This looks like it. It even includes "Economic events". I'll tag this as the accepted answer if no free alternative shows up. Have an upvote for now. – André Christoffer Andersen Apr 25 '17 at 21:00