3
$\begingroup$

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?

Thanks in advance

$\endgroup$

1 Answer 1

5
$\begingroup$

You can use the DiscountCurve class, that takes a list of dates and a list of corresponding discount factors.

The one exported by default in the Python module uses a log-linear interpolation between the given discounts; using a different interpolation would require adding a line in the corresponding SWIG interface and recompiling the module.

$\endgroup$
2
  • $\begingroup$ 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? $\endgroup$
    – Daniel
    Nov 16, 2016 at 15:28
  • $\begingroup$ I'm guessing that the pricing code considers the first coupon as already paid and excludes it from the NPV. What evaluation date did you set? How did you initialize the bond? $\endgroup$ Nov 16, 2016 at 18:58

Your Answer

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

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