I have started working on CDS model using Quantlib and as a starting point, utilized code provided in GitHub Quantlib/Python examples with modifications in initial code as given at the end and have following query:
When using Recovery Rate as 0.60, getting error as "RuntimeError: 1st iteration: failed at 3rd alive instrument, pillar June 21st, 2021, maturity June 21st, 2021, reference date March 22nd, 2019: root not bracketed: f[2.22045e-16,1] -> [1.320123e-01,1.328986e-02]" but haven't observed any error when valuing on BBG calculator. Also Recovery Rate of 0.4 provides perfectly fine value. Why this discrepancy with BBG?
todaysDate = Date(22,March,2019); todaysDate = calendar.adjust(todaysDate) Settings.instance().evaluationDate = todaysDate risk_free_rate = YieldTermStructureHandle( FlatForward(todaysDate, 0.01, Actual365Fixed() ) ) recovery_rate = 0.60 quoted_spreads = [ 0.1214, 0.1769, 0.2471, 0.2816] tenors = [ Period(6, Months), Period(1, Years), Period(2, Years),Period(3, Years)]