Using Discount Factors to Build a QuantLib Bond Discount Curve
Summary
The document explains how to price fixed-rate bonds in QuantLib when the discounting term structure is non-flat. It distinguishes a curve built from zero rates, which requires maturities and corresponding yields, from one built directly from discount factors. The suggested approach is to use QuantLib's DiscountCurve with dates paired to published discount factors, then attach the resulting term structure to a bond pricing engine.
The Python interface uses log-linear interpolation between supplied discount factors by default. Choosing another interpolation method requires changing the SWIG interface and rebuilding the module. The discussion is narrowly about curve construction in QuantLib; it does not address how to select economically appropriate inputs, account for credit risk, or evaluate the source and conventions of published factors.
Key ideas
- A non-flat discount curve can be constructed from zero rates or from discount factors.
- QuantLib's DiscountCurve accepts dates paired with discount factors.
- The default Python binding interpolates discount factors log-linearly.
- Using a different interpolation method requires modifying the interface and recompiling the module.
Tags
Full text
# Discounting Curve in Quantlib/Python # 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? Thanks in advance ## Answer by Luigi Ballabio (score 5) https://quant.stackexchange.com/a/31037 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.
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.