# QuantLib-Python: Getting a list of all holidays between D1 & D2 with function “holidayList”

I figured out that the C++ version of QuantLib offers a function called holidayList in the calendar class.

//! Returns the holidays between two dates
static std::vector<Date> holidayList(const Calendar& calendar,
const Date& from,
const Date& to,
bool includeWeekEnds = false);


I tried to get all holidays between two dates by using this call:

TARGET_calendar = TARGET()
TARGET_calendar.holidayList(TARGET_calendar, Date(1,1,2015), Date(1,1,2016))

AttributeError: 'TARGET' object has no attribute 'holidayList'


Since I am not so familliar with converting C++ to Python, I also tried:

holidayList(TARGET_calendar, Date(1,1,2015), Date(1,1,2016))

NameError: name 'holidayList' is not defined


Can anybody help me out, please?

Thank you very much!

The holidayList() function is not exposed in Python: https://github.com/lballabio/QuantLib-SWIG/blob/master/SWIG/calendars.i

You can submit an issue asking for it to be added, or do it yourself via a pull request or just locally but in this last case you'd have to rebuild the QuantLib Python library, etc.

As a workaround, you can use the isHoliday() function in order to get this list, combined with isWeekend() if you want want to exclude the weekends from the holidays list:

TARGET_calendar = TARGET()
date = Date(1,1,2015)
holiday_list = []
while date < Date(1,1,2016):
if(TARGET_calendar.isHoliday(date) and not
TARGET_calendar.isWeekend(date.weekday())):
holiday_list.append(date)
date = date + Period(1, Days)

• In case you want to open an issue, the place to do it is github.com/lballabio/QuantLib-SWIG/issues. – Luigi Ballabio May 14 '18 at 9:09
• Dear byouness, dear Luigi! Thank you very much for your answers. The workaround warks like a charm. Thanks! Unfortunately I am a beginner in Python and have no idea about C++ so I am not able to integrate the function myself. I have opened an issue here: github.com/lballabio/QuantLib-SWIG/issues/112 – Bernd May 14 '18 at 15:36
• Hello @BerndMeyer! Glad that this helped. If it answers your question, please mark it as accepted so that people who have the same question can find it more quickly. Thanks. – byouness Jun 5 '18 at 16:12