Holiday files for G20 countries

Thomas Browne picture Thomas Browne · Jun 23, 2009 · Viewed 7.1k times · Source

For proper financial FX option pricing I require the exact number of business days between two dates. These dates can be up to 10 years in the future, for 2 different countries. I therefore need to know, in advance the holidays for both of those countries between the two dates. I plan to restrict myself to G20 countries for now.

Anybody know if Python modules exist which have holiday lists included?

Anywhere else to find holiday lists/files?

Answer

Andre Miras picture Andre Miras · Jan 30, 2014

Edit: Updated the link from from novapost's github repo.

I recently came across https://github.com/peopledoc/workalendar. I use it for France and it works like a charm.

"""
>>> from datetime import date
>>> from workalendar.europe import France
>>> cal = France()
>>> cal.holidays(2013)
[(datetime.date(2013, 1, 1), 'New year'),
 (datetime.date(2013, 4, 1), 'Easter Monday'),
 (datetime.date(2013, 5, 1), 'Labour Day'),
 (datetime.date(2013, 5, 8), 'Victory in Europe Day'),
 (datetime.date(2013, 5, 9), 'Ascension Thursday'),
 (datetime.date(2013, 5, 20), 'Whit Monday'),
 (datetime.date(2013, 5, 30), 'Corpus Christi'),
 (datetime.date(2013, 7, 14), 'Bastille Day'),
 (datetime.date(2013, 8, 15), 'Assumption of Mary to Heaven'),
 (datetime.date(2013, 11, 1), 'All Saints Day'),
 (datetime.date(2013, 11, 11), 'Armistice Day'),
 (datetime.date(2013, 12, 25), 'Christmas Day')]
>>> cal.is_working_day(date(2013, 12, 25))  # it's Christmas
False
>>> cal.is_working_day(date(2013, 12, 29))  # it's Sunday
False
>>> cal.is_working_day(date(2013, 12, 26))
True