Skip to content
All library documents

How QuantLib Advances Dates on the Japan Business Calendar

Article Quant Q&A · Author: AUK1939

Summary

The document explains a surprising QuantLib date-advance result using the Japan business calendar. Advancing December 28, 2012 by one business day or by one week both returns January 4, 2013, while advancing by five business days returns January 10. The answer notes that the starting date was a Friday and then accounts for the intervening weekend and year-end holidays: December 31 and January 1 through January 3 are non-working days.

Under the calendar’s business-day adjustment, January 4 is the next working day after the trade date. This explains the one-day result and why a one-week period does not simply mean five business days in the example. The questioner wanted to use the period for a one-week option expiry, but the response does not fully define expiry conventions or explain all QuantLib period and adjustment settings. The example therefore clarifies this calendar case without establishing a universal option-expiry rule.

Key ideas

  • QuantLib advances dates using the selected calendar’s business-day rules.
  • Japan’s year-end holidays make January 4, 2013 the next business day after December 28, 2012.
  • A one-week period and a one-business-day advance can therefore land on the same date in this example.
  • The response does not specify a general convention for calculating option expiry.

Tags

Full text
# Quantlib Calendar Advance


# Quantlib Calendar Advance












Hi I'm trying to advance a business date (28-12-2012) by 1 day and 1 week according to the Japan calendar.

```
import QuantLib as ql

trade_date = ql.Date(28, 12, 2012)
calendar = ql.Japan()

calendar.advance(trade_date, ql.Period('1D'))
Out[23]: Date(4,1,2013)

calendar.advance(trade_date, ql.Period('1W'))
Out[24]: Date(4,1,2013)
```

Seems a bit strange advancing the trade date by one day or one week give the same result. Any ideas why this might be the case? The 1 day result looks right. But the 1 week result seems off.

Incidentally

```
calendar.advance(ql_trade_date, ql.Period('5D'))
Out[25]: Date(10,1,2013)
```

How is `calendar.advance(ql_trade_date, ql.Period('1W'))` to be interpreted? I was trying to compute the expiry of a 1 week option.

## Answer by Dimitri Vulis (score 1)

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

A decent calendar library should go beyond ql.Japan().isBusinessDay(d) and be able to explain why a day is not a business day.

December 28, 2012 is a Friday, a working day.

December 29, 2012 is a Saturday, not a working day.

December 30, 2012 is a Sunday, not a working day.

December 31, 2012 is a December 31 bank holiday https://www.timeanddate.com/holidays/japan/december-31-bank-holiday

January 1, 2013 is New year's day

January 2, 2013 is January 2 bank holiday https://www.timeanddate.com/holidays/japan/january-2-bank-holiday

January 3, 2013 is January 3 bank holiday https://www.timeanddate.com/holidays/japan/january-3-bank-holiday

January 4, 2013 is Friday, the next working day after December 28, 2012.

You may find these comments in the code helpful: https://rkapl123.github.io/QLAnnotatedSource/dc/d44/class_quant_lib_1_1_japan.html

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.