1
$\begingroup$

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()

$\endgroup$
2
  • 1
    $\begingroup$ From a first look: did you make sure that your coupons / prices are in like units, i.e. in nats: 0.02 = 2%, 1.00 = 100% and so on? $\endgroup$ Jan 7 at 11:10
  • $\begingroup$ Are you sure that AUD swap rates use daycount Actual/360, like USD, rather than Actual/365, ike GBP? $\endgroup$ Jan 7 at 14:01
3
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ hi David, thank you very much for the answer, you're right about the quotation. I'm using cross currency basis swap which is quoted in basis points so it should be using price/10,000 to get the actual spread rate. there was a change made to security_typ field on BBG which caused my logic broken. the BBG field used to return basis swap but now returns 'swap', so we have to source the information from a new BBG field called security_typ2.what is the better helper in this case if i need to use cross currency basis swap rates to boostrapping AUD discount curve? $\endgroup$
    – user51725
    Jan 8 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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