Skip to content
All library documents

Fixing Coupon-Scale Errors in QuantLib Yield-Curve Bootstrapping

Article Quant Q&A · Author: user51725

Summary

This question describes a QuantLib curve-building failure while using Australian market data and fixed-rate bond helpers. The reported error occurs when the long-dated instruments are included, and the supplied coupon inputs are 0.1838 and 0.165. The response identifies a likely scale mismatch: those values are interpreted as coupon rates of 18.38% and 16.5%, rather than as percentages expressed in whole-number form.

The proposed correction is to convert the quoted percentage values to decimal rates before passing them as coupons. The answer also notes that fixed-rate bond helpers may not be the best choice when bootstrapping a swap curve, suggesting that instrument-helper choice should match the curve being built. The document does not show the revised curve or demonstrate the fix against the stated market data, so the diagnosis is an answer to the reported setup rather than a validated general result.

Key ideas

  • Coupon inputs must use the rate scale expected by the helper.
  • Values intended as percentages should be converted to decimal coupon rates.
  • A coupon-scale mismatch can prevent the bootstrap solver from finding a root.
  • Swap-specific helpers may be more appropriate than fixed-rate bond helpers for a swap curve.

Tags

Full text
# QuantLib constructing yield curve error: root not bracketed


# QuantLib constructing yield curve error: root not bracketed












much appreciated if anyone can help with the below, basically i'm trying to construct a yield curve using some real market data. I have pasted the python code below. I use a list of swap rates and getting some root not bracketed errors, after removing some swap rates, I'm left with 9y and 10y AUD swap rates. As long as these two are included, then the curve construction won't work. believe these are real market data as of 2021-01-04. the error I'm getting:

RuntimeError: 1st iteration: failed at 2nd alive instrument, pillar January 6th, 2031, maturity January 6th, 2031, reference date January 4th, 2021: root not bracketed: f[0.0830554,0.627492] -> [-3.376389e+01,-1.733717e+01]

```
import QuantLib as ql

swapHelpers = []

pricingDate = ql.DateParser.parseFormatted('2021-01-04', '%Y-%m-%d')
effectiveDate = ql.DateParser.parseFormatted('2021-01-06', '%Y-%m-%d')
dayCount = ql.Actual360()
terminationDate1 = ql.DateParser.parseFormatted('2031-01-06', '%Y-%m-%d')
schedule1 = ql.Schedule(effectiveDate,
                       terminationDate1,
                       ql.Period(ql.Quarterly),
                       ql.Australia(),
                       ql.ModifiedFollowing,
                       ql.ModifiedFollowing,
                       ql.DateGeneration.Backward,
                       False)
helper1 = ql.FixedRateBondHelper(ql.QuoteHandle(ql.SimpleQuote(100)),
                                2,
                                100,
                                schedule1,
                                [0.1838],
                                dayCount,
                                ql.ModifiedFollowing,
                                )
swapHelpers.append(helper1)
terminationDate2 = ql.DateParser.parseFormatted('2030-01-06', '%Y-%m-%d')
schedule2 = ql.Schedule(effectiveDate,
               terminationDate2,
               ql.Period(ql.Quarterly),
               ql.Australia(),
               ql.ModifiedFollowing,
               ql.ModifiedFollowing,
               ql.DateGeneration.Backward,
               False)
helper2 = ql.FixedRateBondHelper(ql.QuoteHandle(ql.SimpleQuote(100)),
                                    2,
                                    100,
                                    schedule2,
                                    [0.165],
                                    dayCount,
                                    ql.ModifiedFollowing,
                                    )
swapHelpers.append(helper2)
yieldcurve = ql.PiecewiseLogCubicDiscount(pricingDate,
                                          swapHelpers,
                                          ql.Actual360())

yieldcurve.enableExtrapolation()
yieldcurve.dates()
```

## Answer by David Duarte (score 3)

https://quant.stackexchange.com/a/60385

You are inputting coupons of 18.38% and 16.5% which is probably not what you want and making the solver not find a solution.

Change the coupons to [0.1838/100] and [0.165/100] and you should be Ok.

Also, if you are bootstrapping a swap curve, there are other helpers more appropriate than the `FixedRateBondHelper`

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.