I want to create a TermStructureHandle handle in python using quantlib. I use the DiscountCurve class and enter the list of dates and discount factors as follows:

dates = [ql.Date(9,4,2018), ql.Date(9,4,2019), ql.Date(9,4,2020)] 
discfactors = [1, 0.9, 0.8] 
dayCount = ql.ActualActual() 
disc_curve = ql.DiscountCurve(dates, discfactors, dayCount) 
term_structure = ql.YieldTermStructureHandle(disc_curve) 

The discount factor derived from this termstructure for two years should be 0.8 but in fact I get


What is the reason for this? When I insert longer lists of dates and corresponding discount factors the difference keeps increasing.


1 Answer 1


Note that the DCF between ql.Date(9,4,2018) and ql.Date(9,4,2020) is not 2 under Act/Act, it is 2.0019987.

So you could either use


or set your DayCountConvention to 30/360, under which the DCF is in fact 2.

  • $\begingroup$ Or use term_structure.discount(ql.Date(9,4,2020)). I don't suggest using Act/Act or 30/360 as day counters for the curve, though, as they can give surprising results for some dates. Simple ones like Act/360 or Act/365 are better. $\endgroup$ Apr 11, 2018 at 9:36
  • $\begingroup$ @LuigiBallabio You are absolutely right, Act/360 or Act/365 are a lot "safer" (e.g. for days around month-ends). But it is worth noting that in reality you are bound by market conventions, meaning you cannot always opt for the "safe" option. $\endgroup$
    – Phil-ZXX
    Apr 11, 2018 at 11:26
  • $\begingroup$ True. Note, though, that if one uses the interfaces taking dates (as the one above) the day count passed to the curve will only be used internally. You can retrieve rates from the curve according to any other day count. I agree, sometimes it's not possible to account for all market conventions this way, but the times it happens are fewer than it seems at first sight. $\endgroup$ Apr 11, 2018 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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