I wanted to calculate the number of trading days between 2 given days. There is a discussion in https://stackoverflow.com/questions/62292979/using-quantlib-in-python-how-do-i-get-the-number-of-days-between-two-dates.

However this considers the day-count convention from the Bond coupon's calculation perspective using something Thirty360().

However I wonder why we dont consider a calendar for such calculation? Is there any way to consider the holiday information as well in the day-count calculation?

  • $\begingroup$ Just curious, is this in the context of Brazilian BUS/252 daycount convention? In markets with history of high inflation, sometimes interest is only accrued on business days, not on holidays and weekends, which is why you need the number of business days (rather than actual calendar days) between two dates using specified holiday calendar. Quanttlib does have a Business252 daycounter, but I don't see a way to ql.Business252().daycount(start,end,sao paolo) $\endgroup$ Sep 19, 2020 at 14:56
  • $\begingroup$ Not really. I was investigating about a general day counter between 2 days for QuantLib's Date class, and wondering how and why that calculation cant take the calendar information. But, Brazilian BUS/252 is equally interesting anyway.. $\endgroup$
    – Bogaso
    Sep 19, 2020 at 15:07
  • $\begingroup$ The "number of business days" calculation is needed inside BUS/252. have you tried the businessDaysBetween method? rkapl123.github.io/QLAnnotatedSource/da/d3e/… $\endgroup$ Sep 19, 2020 at 15:11

1 Answer 1


If you want the number of business days acording to a calendar, you can use the businessDaysBetween method from the calendar object, like this:

import QuantLib as ql
d1 = ql.Date(15,3,2020)
d2 = ql.Date(15,6,2020)
cal = ql.TARGET()
days = cal.businessDaysBetween(d1, d2)


  • $\begingroup$ Thanks. Is it also possible to get the vector of business days between the 2 given dates based on applicable calendar? $\endgroup$
    – Bogaso
    Sep 19, 2020 at 16:32
  • 1
    $\begingroup$ Yes, that would be cal.businessDayList(d1, d2) $\endgroup$ Sep 19, 2020 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.