# Discounting Curve in Quantlib/Python

I'm using Python 2.7.12 with the QuantLib package. I'm trying to price fixed bonds. I understand how to create a bond object. How to get the "right" discounting curve is kind of a problem. Assuming a non-flat term structure, I have seen the ql.ZeroCurve function:

spotCurve = ql.ZeroCurve(spotDates, spotRates, dayCount, calendar, interpolation, compounding, compoundingFrequency)
spotCurveHandle = ql.YieldTermStructureHandle(spotCurve)
bondEngine = ql.DiscountingBondEngine(spotCurveHandle)
fixedRateBond.setPricingEngine(bondEngine)


I assume the inputs are the maturities and yields of zeros with the same "risk" as the bond, we are looking at.

How can I specify the discount curve directly, e.g. when having the discount factors published by authorities like the FED or the ECB?

You can use the DiscountCurve class, that takes a list of dates and a list of corresponding discount factors.
• Thanks for your reply. I tried it as follows: discDates = [ql.Date(15, 1, 2015), ql.Date(15, 1, 2016), ql.Date(16, 1, 2017)] discRates = [1, 0.9, 0.8] discountCurve = ql.DiscountCurve(discDates, discRates, dayCount) .... bondEngine = ql.DiscountingBondEngine(spotCurveHandle) fixedRateBond.setPricingEngine(bondEngine)  with a bond paying 6 on 15th Jan 2015, 2016 and 106 in 2017. I would expect a NPV of 96.2 but the fixedRateBond.NPV function gives me 90,2. Is my expectation not correct or am I coding it wrong? Nov 16, 2016 at 15:28