Skip to content
All library documents

Building a Custom QuantLib Calendar from Holiday Dates

Article Quant Q&A · Author: Surima Jain

Summary

The document asks how to create a QuantLib business calendar from a supplied list of holidays and weekends when standard country or currency calendars do not match the relevant market schedule. The answer shows the basic approach: start with a weekends-only calendar and add each exceptional holiday date. If the market’s weekend pattern is itself nonstandard, the answer recommends beginning with a null calendar instead, so the default weekend rules do not apply.

This is a concise implementation pointer rather than a full calendar-design guide. It does not explain how to represent custom weekend days, verify date parsing, or test business-day and holiday behavior across a full schedule. Users will need to ensure their date list and baseline calendar reflect the conventions their instruments or data require. The example establishes that calendars can be adjusted through added holidays, while the alternative starting point accommodates schedules that cannot use the ordinary weekends-only assumption.

Key ideas

  • A weekends-only QuantLib calendar can serve as a base for a custom holiday schedule.
  • Add each supplied holiday date to the calendar.
  • Start with a null calendar when the standard weekend pattern is unsuitable.
  • The example does not detail how to configure custom weekend days or validate a complete market calendar.

Tags

Full text
# Is there a way to create a custom calendar using a holiday and weekend list in quantlib


# Is there a way to create a custom calendar using a holiday and weekend list in quantlib












We have a data set up that provides us a list of holidays and weekends which is different from the country or currency calendars.Is there any method exposed in Quantlib calendars which expects a list of holday dates and weekends to form a calendar?

## Answer by David Duarte (score 1)

https://quant.stackexchange.com/a/55626

Something like this?

```
myCalendar = ql.WeekendsOnly()
dates = ['19-06-2019', '07-05-2020']
for date in dates:
    myCalendar.addHoliday( ql.Date(date, '%d-%m-%Y') )
```

Or if for some reason the weekends are different, start from `ql.NullCalendar()`

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.