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
print(abs(discfactors[2]-term_strcuture.discount(2)))
0.00018797232855949364
What is the reason for this? When I insert longer lists of dates and corresponding discount factors the difference keeps increasing.