QuantLib in R: Bond Setup
Asked Answered
D

2

7

I'm trying to build a US Treasury curve spline through QuantLib using the exponential spline fitting function. However, I'm getting very odd results and can't figure out why. Namely, negative rates from the generated discount curve where the inputs are all positive yields and there is huge variation in the front-end yields (graph below).

I'm feeding the function the entire universe of bonds > 1Y, which results in some repeated maturities (for bonds issued at different times and rolling down the curve), so I'm not sure if that's causing some fitting issues. The entire dataframe (named df in the code) I'm using is shown at the bottom.

This is my code to fit the curve and the corresponding data below. (the 'YrsToMat' column is generated by YrsToMat<- sapply(maturities, yearFraction, startDates = Sys.Date(), dayCounters = 9) #9 = ActualActual.Bond where maturities was a list of all the bonds maturities).

Thanks for any help!

library(RQuantLib)

YrsToMat <- df$YrsToMat
marketQuotes <- df$Prices
cpn_rates <- df$Coupons

dateparams <- list(settlementDays=1, period="Semiannual", 
                   dayCounter="ActualActual.Bond", 
                   businessDayConvention ="ModifiedFollowing")

curveparams <- list(method="ExponentialSplinesFitting", 
                    origDate = Sys.Date())

curve <- FittedBondCurve(curveparams, YrsToMat, cpn_rates, marketQuotes, dateparams)

Output Plot

structure(list(ISIN = structure(1:261, .Label = c("US912810EM63", 
"US912810EN47", "US912810EP94", "US912810EQ77", "US912810ES34", 
"US912810ET17", "US912810EV62", "US912810EW46", "US912810EX29", 
"US912810EY02", "US912810EZ76", "US912810FA17", "US912810FB99", 
"US912810FE39", "US912810FF04", "US912810FG86", "US912810FJ26", 
"US912810FM54", "US912810FP85", "US912810FT08", "US912810PT97", 
"US912810PU60", "US912810PW27", "US912810PX00", "US912810QA97", 
"US912810QB70", "US912810QC53", "US912810QD37", "US912810QE10", 
"US912810QH41", "US912810QK79", "US912810QL52", "US912810QN19", 
"US912810QQ40", "US912810QS06", "US912810QT88", "US912810QU51", 
"US912810QW18", "US912810QX90", "US912810QY73", "US912810QZ49", 
"US912810RB61", "US912810RC45", "US912810RD28", "US912810RE01", 
"US912810RG58", "US912810RH32", "US912810RJ97", "US912810RK60", 
"US912810RM27", "US912810RN00", "US912810RP57", "US912810RQ31", 
"US912810RS96", "US912810RT79", "US912810RU43", "US912810RV26", 
"US912810RX81", "US912810RY64", "US912810RZ30", "US912810SA79", 
"US912810SC36", "US912810SD19", "US912810SE91", "US912810SF66", 
"US912810SH23", "US912810SJ88", "US912810SK51", "US912810SL35", 
"US912810SN90", "US912810SP49", "US912810SQ22", "US912810SR05", 
"US912810SS87", "US9128282A70", "US9128282D10", "US9128282N91", 
"US9128282P40", "US9128282R06", "US9128282S88", "US9128282U35", 
"US9128282W90", "US9128282Y56", "US9128283C28", "US9128283D01", 
"US9128283F58", "US9128283J70", "US9128283P31", "US9128283U26", 
"US9128283V09", "US9128283W81", "US9128283Z13", "US9128284A52", 
"US9128284D91", "US9128284F40", "US9128284L18", "US9128284M90", 
"US9128284N73", "US9128284R87", "US9128284S60", "US9128284U17", 
"US9128284V99", "US9128284X55", "US9128284Z04", "US9128285C00", 
"US9128285D82", "US9128285J52", "US9128285K26", "US9128285M81", 
"US9128285N64", "US9128285P13", "US9128285R78", "US9128285T35", 
"US9128285U08", "US9128285V80", "US9128285Z94", "US9128286A35", 
"US9128286B18", "US9128286C90", "US9128286F22", "US9128286G05", 
"US9128286H87", "US9128286L99", "US9128286M72", "US9128286R69", 
"US9128286S43", "US9128286T26", "US9128286U98", "US9128286X38", 
"US9128286Y11", "US9128286Z85", "US9128287B09", "US9128287C81", 
"US912828B667", "US912828D564", "US912828G385", "US912828G534", 
"US912828G872", "US912828H862", "US912828J272", "US912828J439", 
"US912828J769", "US912828K742", "US912828L245", "US912828L575", 
"US912828M490", "US912828M565", "US912828M805", "US912828N308", 
"US912828P386", "US912828P469", "US912828P790", "US912828Q293", 
"US912828R283", "US912828R366", "US912828R697", "US912828S356", 
"US912828S927", "US912828SF82", "US912828SV33", "US912828T263", 
"US912828T917", "US912828TJ95", "US912828TY62", "US912828U246", 
"US912828U576", "US912828U659", "US912828U816", "US912828UN88", 
"US912828V236", "US912828V723", "US912828V806", "US912828V988", 
"US912828VB32", "US912828VS66", "US912828W481", "US912828W556", 
"US912828W713", "US912828W895", "US912828WE61", "US912828WJ58", 
"US912828WZ90", "US912828X471", "US912828X703", "US912828X885", 
"US912828XB14", "US912828XD79", "US912828XG01", "US912828XQ82", 
"US912828XR65", "US912828XT22", "US912828XW50", "US912828XX34", 
"US912828XZ81", "US912828Y610", "US912828Y792", "US912828Y875", 
"US912828Y958", "US912828YA22", "US912828YB05", "US912828YD60", 
"US912828YE44", "US912828YF19", "US912828YG91", "US912828YH74", 
"US912828YK04", "US912828YM69", "US912828YQ73", "US912828YS30", 
"US912828YT13", "US912828YU85", "US912828YV68", "US912828YW42", 
"US912828YX25", "US912828YY08", "US912828YZ72", "US912828Z294", 
"US912828Z526", "US912828Z609", "US912828Z781", "US912828Z864", 
"US912828Z948", "US912828ZA13", "US912828ZB95", "US912828ZC78", 
"US912828ZD51", "US912828ZE35", "US912828ZF00", "US912828ZG82", 
"US912828ZH65", "US912828ZL77", "US912828ZM50", "US912828ZN34", 
"US912828ZP81", "US912828ZQ64", "US912828ZR48", "US912828ZS21", 
"US912828ZT04", "US912828ZU76", "US912828ZV59", "US912828ZW33", 
"US912828ZX16", "US912828ZY98", "US91282CAB72", "US91282CAC55", 
"US91282CAD39", "US91282CAE12", "US91282CAF86", "US91282CAG69", 
"US91282CAH43", "US91282CAJ09", "US91282CAK71", "US91282CAL54", 
"US91282CAM38", "US91282CAN11", "US91282CAP68", "US91282CAR25", 
"US91282CAT80", "US91282CAU53", "US91282CAV37", "US91282CAW10"
), class = "factor"), YrsToMat = c(1, 1, 1, 1.08333333333333, 
1.08333333333333, 1.08333333333333, 1.08333333333333, 1.16666666666667, 
1.16666666666667, 1.16666666666667, 1.16666666666667, 1.25, 1.25, 
1.25, 1.25, 1.25, 1.33333333333333, 1.33333333333333, 1.33333333333333, 
1.33333333333333, 1.41666666666667, 1.41666666666667, 1.41666666666667, 
1.41666666666667, 1.5, 1.5, 1.5, 1.5, 1.5, 1.58333333333333, 
1.58333333333333, 1.58333333333333, 1.58333333333333, 1.66666666666667, 
1.66666666666667, 1.66666666666667, 1.66666666666667, 1.75, 1.75, 
1.75, 1.75, 1.75, 1.75, 1.83333333333333, 1.83333333333333, 1.83333333333333, 
1.83333333333333, 1.91666666666667, 1.91666666666667, 1.91666666666667, 
1.91666666666667, 2, 2, 2, 2.08333333333333, 2.08333333333333, 
2.16666666666667, 2.16666666666667, 2.16666666666667, 2.25, 2.25, 
2.25, 2.25, 2.25, 2.33333333333333, 2.33333333333333, 2.33333333333333, 
2.41666666666667, 2.41666666666667, 2.41666666666667, 2.5, 2.5, 
2.5, 2.5, 2.58333333333333, 2.58333333333333, 2.58333333333333, 
2.66666666666667, 2.66666666666667, 2.66666666666667, 2.75, 2.75, 
2.75, 2.75, 2.75, 2.83333333333333, 2.83333333333333, 2.83333333333333, 
2.91666666666667, 2.91666666666667, 2.91666666666667, 3, 3, 3, 
3, 3.08333333333333, 3.08333333333333, 3.16666666666667, 3.16666666666667, 
3.25, 3.25, 3.25, 3.33333333333333, 3.41666666666667, 3.41666666666667, 
3.5, 3.5, 3.58333333333333, 3.58333333333333, 3.66666666666667, 
3.66666666666667, 3.75, 3.75, 3.75, 3.83333333333333, 3.83333333333333, 
3.91666666666667, 3.91666666666667, 4, 4, 4, 4, 4.08333333333333, 
4.08333333333333, 4.16666666666667, 4.16666666666667, 4.25, 4.25, 
4.25, 4.25, 4.33333333333333, 4.33333333333333, 4.41666666666667, 
4.41666666666667, 4.5, 4.5, 4.5, 4.58333333333333, 4.58333333333333, 
4.66666666666667, 4.66666666666667, 4.75, 4.75, 4.75, 4.75, 4.83333333333333, 
4.83333333333333, 4.91666666666667, 4.91666666666667, 5, 5, 5.08333333333333, 
5.16666666666667, 5.25, 5.25, 5.25, 5.33333333333333, 5.41666666666667, 
5.5, 5.5, 5.58333333333333, 5.66666666666667, 5.75, 5.75, 5.75, 
5.83333333333333, 5.91666666666667, 6, 6, 6, 6.08333333333333, 
6.16666666666667, 6.25, 6.25, 6.25, 6.33333333333333, 6.41666666666667, 
6.5, 6.5, 6.58333333333333, 6.66666666666667, 6.75, 6.75, 6.75, 
6.83333333333333, 6.91666666666667, 7, 7, 7.25, 7.5, 7.75, 7.75, 
8, 8, 8.25, 8.25, 8.5, 8.75, 8.75, 9, 9.25, 9.5, 9.5, 9.75, 10, 
10.25, 15.25, 16.25, 16.5, 17.25, 17.5, 18.25, 18.5, 18.75, 19, 
19.25, 19.5, 19.5, 19.75, 19.75, 20, 20.25, 20.5, 20.75, 21, 
21.25, 21.5, 21.75, 22, 22.25, 22.5, 22.75, 23, 23.25, 23.5, 
23.75, 24, 24.25, 24.5, 24.75, 25, 25.25, 25.5, 25.75, 26, 26.25, 
26.5, 26.75, 27, 27.25, 27.5, 27.75, 28, 28.25, 28.5, 28.75, 
29, 29.25, 29.5, 29.75, 30), Coupons = c(0.0725, 0.07625, 0.07125, 
0.0625, 0.075, 0.07625, 0.06875, 0.06, 0.0675, 0.065, 0.06625, 
0.06375, 0.06125, 0.055, 0.0525, 0.0525, 0.06125, 0.0625, 0.05375, 
0.045, 0.0475, 0.05, 0.04375, 0.045, 0.035, 0.0425, 0.045, 0.04375, 
0.04625, 0.04375, 0.03875, 0.0425, 0.0475, 0.04375, 0.0375, 0.03125, 
0.03125, 0.03, 0.0275, 0.0275, 0.03125, 0.02875, 0.03625, 0.0375, 
0.03625, 0.03375, 0.03125, 0.03, 0.025, 0.03, 0.02875, 0.03, 
0.025, 0.025, 0.0225, 0.02875, 0.03, 0.03, 0.0275, 0.0275, 0.03, 
0.03125, 0.03, 0.03375, 0.03, 0.02875, 0.0225, 0.02375, 0.02, 
0.0125, 0.01375, 0.01125, 0.01125, 0.01625, 0.015, 0.01375, 0.02125, 
0.01875, 0.0225, 0.01625, 0.01875, 0.01875, 0.02125, 0.02, 0.0225, 
0.0225, 0.02125, 0.0225, 0.02375, 0.025, 0.0275, 0.0275, 0.02625, 
0.025, 0.02625, 0.0275, 0.02875, 0.02875, 0.02875, 0.0275, 0.02625, 
0.02875, 0.0275, 0.0275, 0.03, 0.02875, 0.03, 0.02875, 0.03125, 
0.02875, 0.02875, 0.02625, 0.02625, 0.02625, 0.025, 0.025, 0.02625, 
0.02625, 0.025, 0.025, 0.02375, 0.02375, 0.0225, 0.0225, 0.0225, 
0.02375, 0.02375, 0.02125, 0.02125, 0.0175, 0.0175, 0.01875, 
0.0175, 0.0275, 0.02375, 0.0225, 0.01875, 0.02125, 0.015, 0.02, 
0.0175, 0.0175, 0.02, 0.01875, 0.0175, 0.01875, 0.0225, 0.02, 
0.02125, 0.0175, 0.01625, 0.015, 0.015, 0.01625, 0.01625, 0.01625, 
0.01375, 0.0125, 0.02, 0.0175, 0.01375, 0.01625, 0.01625, 0.01625, 
0.02, 0.02125, 0.0175, 0.02, 0.02, 0.0225, 0.01875, 0.0225, 0.0225, 
0.0175, 0.025, 0.02125, 0.01875, 0.02125, 0.01875, 0.0275, 0.025, 
0.0175, 0.01875, 0.02, 0.02375, 0.02125, 0.01875, 0.02125, 0.02, 
0.0175, 0.02, 0.0175, 0.02, 0.0275, 0.0275, 0.02875, 0.0175, 
0.01875, 0.015, 0.01625, 0.01375, 0.0125, 0.015, 0.01625, 0.015, 
0.01375, 0.015, 0.01625, 0.0175, 0.015, 0.01625, 0.015, 0.01625, 
0.0175, 0.0175, 0.01625, 0.015, 0.01375, 0.01375, 0.015, 0.01375, 
0.015, 0.01125, 0.01125, 0.01125, 0.005, 0.00625, 0.005, 0.00375, 
0.0025, 0.00375, 0.00125, 0.005, 0.00125, 0.00625, 0.00125, 0.005, 
0.0025, 0.0025, 0.005, 0.0025, 0.00125, 0.00125, 0.0025, 0.00125, 
0.00375, 0.00625, 0.00125, 0.00125, 0.005, 0.0025, 0.00125, 0.00375, 
0.0025, 0.00125, 0.00125, 0.00125, 0.0025, 0.005, 0.00875, 0.0025
), Prices = c(112.171875, 114.67578125, 115.3828125, 116.453125, 
128.5234375, 130.66015625, 130.43359375, 128.796875, 135.42578125, 
135.29296875, 137.3203125, 138.22265625, 137.73046875, 136.21875, 
135.2421875, 136.1328125, 145.53125, 149.71484375, 144.4609375, 
147.91796875, 153.69140625, 158.04296875, 149.96875, 152.41796875, 
137.05859375, 149.8046875, 154.43359375, 152.6796875, 157.375, 
153.328125, 144.58203125, 151.64453125, 161.16796875, 154.66015625, 
143.1875, 131.78125, 132.09375, 129.5859375, 124.87109375, 124.765625, 
132.125, 127.30078125, 142.25, 144.9296875, 142.59765625, 137.7265625, 
132.74609375, 130.265625, 119.9609375, 130.57421875, 128.0078125, 
130.91015625, 120.2265625, 120.26953125, 114.88671875, 128.625, 
131.625, 131.76953125, 126.2265625, 126.40234375, 132.16796875, 
135.171875, 132.46484375, 141.47265625, 132.8125, 129.984375, 
115.28125, 118.359375, 109.4609375, 91.390625, 94.30859375, 95.36328125, 
95.609375, 100.34375, 105.66796875, 103.2265625, 106.765625, 
102.875, 110.8515625, 102.5703125, 105.9453125, 103.14453125, 
107.0078125, 103.52734375, 107.6171875, 111.05859375, 107.2421875, 
107.890625, 104.77734375, 109.0625, 114.7421875, 110.24609375, 
105.50390625, 105.41796875, 109.87109375, 106.19921875, 111.12109375, 
115.94140625, 111.29296875, 106.3984375, 106.2890625, 116.26171875, 
106.9921875, 111.1953125, 112.546875, 107.55859375, 112.7109375, 
107.76171875, 118.51953125, 112.2578125, 107.96484375, 102.6328125, 
111.1640625, 107.3984375, 102.69921875, 107.1953125, 111.30078125, 
114.90234375, 102.890625, 110.76171875, 106.921875, 102.90625, 
109.55078125, 102.916015625, 106.80078125, 110.32421875, 113.126953125, 
102.896484375, 109.046875, 102.48046875, 105.3046875, 107.734375, 
102.60546875, 108.078125, 107.765625, 107.68359375, 101.783203125, 
102.1953125, 101.625, 107.00390625, 102.029296875, 102.169921875, 
107.61328125, 103.005859375, 102.919921875, 103.2890625, 109.10546875, 
103.67578125, 104.07421875, 103.4296875, 106.1796875, 102.96484375, 
103.0859375, 103.48046875, 106.29296875, 103.58984375, 103.05859375, 
102.8125, 102.30078125, 102.3515625, 103.31640625, 104.125, 102.52734375, 
102.865234375, 108.66796875, 105.73828125, 101.658203125, 102.05078125, 
104.02734375, 106.25, 102.0625, 106.3984375, 110.3984375, 103.83984375, 
106.25390625, 106.109375, 102.201171875, 106.24609375, 102.328125, 
107.5078125, 107.73828125, 102.29296875, 102.46875, 105.95703125, 
111.41796875, 107.87109375, 102.60546875, 103.1328125, 103.0859375, 
102.421875, 106.0703125, 102.54296875, 106.203125, 110.8828125, 
106.8125, 111.625, 105.390625, 107.77734375, 102.3046875, 107.08203125, 
104.9765625, 103.6015625, 102.40234375, 106.4296875, 104.61328125, 
102.2734375, 104.68359375, 106.453125, 108.2421875, 101.40625, 
106.484375, 104.74609375, 102.98046875, 107.28125, 105.83984375, 
101.646484375, 102.82421875, 104.35546875, 101.474609375, 105.76953125, 
102.64453125, 105.96484375, 101.255859375, 103.4609375, 103.36328125, 
100.73046875, 100.3125, 100.69140625, 100.3203125, 100.16015625, 
100.12109375, 99.98828125, 99.4453125, 99.84765625, 97.9140625, 
99.9765625, 99.3671875, 99.5625, 100.140625, 99.30078125, 99.48828125, 
99.9609375, 99.80859375, 99.44921875, 99.947265625, 98.4296875, 
97.68359375, 99.7890625, 99.9375, 99.15234375, 99.40234375, 99.76171875, 
98.23828125, 99.3515625, 99.931640625, 99.7421875, 99.927734375, 
99.30859375, 99.0078125, 99.91796875, 100.09765625)), row.names = c(NA, 
261L), class = "data.frame")

The df is:

            ISIN  YrsToMat Coupons    Prices
1   US912810EM63  1.000000 0.07250 112.17188
2   US912810EN47  1.000000 0.07625 114.67578
3   US912810EP94  1.000000 0.07125 115.38281
4   US912810EQ77  1.083333 0.06250 116.45312
5   US912810ES34  1.083333 0.07500 128.52344
6   US912810ET17  1.083333 0.07625 130.66016
7   US912810EV62  1.083333 0.06875 130.43359
8   US912810EW46  1.166667 0.06000 128.79688
9   US912810EX29  1.166667 0.06750 135.42578
10  US912810EY02  1.166667 0.06500 135.29297
11  US912810EZ76  1.166667 0.06625 137.32031
12  US912810FA17  1.250000 0.06375 138.22266
13  US912810FB99  1.250000 0.06125 137.73047
14  US912810FE39  1.250000 0.05500 136.21875
15  US912810FF04  1.250000 0.05250 135.24219
16  US912810FG86  1.250000 0.05250 136.13281
17  US912810FJ26  1.333333 0.06125 145.53125
18  US912810FM54  1.333333 0.06250 149.71484
19  US912810FP85  1.333333 0.05375 144.46094
20  US912810FT08  1.333333 0.04500 147.91797
21  US912810PT97  1.416667 0.04750 153.69141
22  US912810PU60  1.416667 0.05000 158.04297
23  US912810PW27  1.416667 0.04375 149.96875
24  US912810PX00  1.416667 0.04500 152.41797
25  US912810QA97  1.500000 0.03500 137.05859
26  US912810QB70  1.500000 0.04250 149.80469
27  US912810QC53  1.500000 0.04500 154.43359
28  US912810QD37  1.500000 0.04375 152.67969
29  US912810QE10  1.500000 0.04625 157.37500
30  US912810QH41  1.583333 0.04375 153.32812
31  US912810QK79  1.583333 0.03875 144.58203
32  US912810QL52  1.583333 0.04250 151.64453
33  US912810QN19  1.583333 0.04750 161.16797
34  US912810QQ40  1.666667 0.04375 154.66016
35  US912810QS06  1.666667 0.03750 143.18750
36  US912810QT88  1.666667 0.03125 131.78125
37  US912810QU51  1.666667 0.03125 132.09375
38  US912810QW18  1.750000 0.03000 129.58594
39  US912810QX90  1.750000 0.02750 124.87109
40  US912810QY73  1.750000 0.02750 124.76562
41  US912810QZ49  1.750000 0.03125 132.12500
42  US912810RB61  1.750000 0.02875 127.30078
43  US912810RC45  1.750000 0.03625 142.25000
44  US912810RD28  1.833333 0.03750 144.92969
45  US912810RE01  1.833333 0.03625 142.59766
46  US912810RG58  1.833333 0.03375 137.72656
47  US912810RH32  1.833333 0.03125 132.74609
48  US912810RJ97  1.916667 0.03000 130.26562
49  US912810RK60  1.916667 0.02500 119.96094
50  US912810RM27  1.916667 0.03000 130.57422
51  US912810RN00  1.916667 0.02875 128.00781
52  US912810RP57  2.000000 0.03000 130.91016
53  US912810RQ31  2.000000 0.02500 120.22656
54  US912810RS96  2.000000 0.02500 120.26953
55  US912810RT79  2.083333 0.02250 114.88672
56  US912810RU43  2.083333 0.02875 128.62500
57  US912810RV26  2.166667 0.03000 131.62500
58  US912810RX81  2.166667 0.03000 131.76953
59  US912810RY64  2.166667 0.02750 126.22656
60  US912810RZ30  2.250000 0.02750 126.40234
61  US912810SA79  2.250000 0.03000 132.16797
62  US912810SC36  2.250000 0.03125 135.17188
63  US912810SD19  2.250000 0.03000 132.46484
64  US912810SE91  2.250000 0.03375 141.47266
65  US912810SF66  2.333333 0.03000 132.81250
66  US912810SH23  2.333333 0.02875 129.98438
67  US912810SJ88  2.333333 0.02250 115.28125
68  US912810SK51  2.416667 0.02375 118.35938
69  US912810SL35  2.416667 0.02000 109.46094
70  US912810SN90  2.416667 0.01250  91.39062
71  US912810SP49  2.500000 0.01375  94.30859
72  US912810SQ22  2.500000 0.01125  95.36328
73  US912810SR05  2.500000 0.01125  95.60938
74  US912810SS87  2.500000 0.01625 100.34375
75  US9128282A70  2.583333 0.01500 105.66797
76  US9128282D10  2.583333 0.01375 103.22656
77  US9128282N91  2.583333 0.02125 106.76562
78  US9128282P40  2.666667 0.01875 102.87500
79  US9128282R06  2.666667 0.02250 110.85156
80  US9128282S88  2.666667 0.01625 102.57031
81  US9128282U35  2.750000 0.01875 105.94531
82  US9128282W90  2.750000 0.01875 103.14453
83  US9128282Y56  2.750000 0.02125 107.00781
84  US9128283C28  2.750000 0.02000 103.52734
85  US9128283D01  2.750000 0.02250 107.61719
86  US9128283F58  2.833333 0.02250 111.05859
87  US9128283J70  2.833333 0.02125 107.24219
88  US9128283P31  2.833333 0.02250 107.89062
89  US9128283U26  2.916667 0.02375 104.77734
90  US9128283V09  2.916667 0.02500 109.06250
91  US9128283W81  2.916667 0.02750 114.74219
92  US9128283Z13  3.000000 0.02750 110.24609
93  US9128284A52  3.000000 0.02625 105.50391
94  US9128284D91  3.000000 0.02500 105.41797
95  US9128284F40  3.000000 0.02625 109.87109
96  US9128284L18  3.083333 0.02750 106.19922
97  US9128284M90  3.083333 0.02875 111.12109
98  US9128284N73  3.166667 0.02875 115.94141
99  US9128284R87  3.166667 0.02875 111.29297
100 US9128284S60  3.250000 0.02750 106.39844
101 US9128284U17  3.250000 0.02625 106.28906
102 US9128284V99  3.250000 0.02875 116.26172
103 US9128284X55  3.333333 0.02750 106.99219
104 US9128284Z04  3.416667 0.02750 111.19531
105 US9128285C00  3.416667 0.03000 112.54688
106 US9128285D82  3.500000 0.02875 107.55859
107 US9128285J52  3.500000 0.03000 112.71094
108 US9128285K26  3.583333 0.02875 107.76172
109 US9128285M81  3.583333 0.03125 118.51953
110 US9128285N64  3.666667 0.02875 112.25781
111 US9128285P13  3.666667 0.02875 107.96484
112 US9128285R78  3.750000 0.02625 102.63281
113 US9128285T35  3.750000 0.02625 111.16406
114 US9128285U08  3.750000 0.02625 107.39844
115 US9128285V80  3.833333 0.02500 102.69922
116 US9128285Z94  3.833333 0.02500 107.19531
117 US9128286A35  3.916667 0.02625 111.30078
118 US9128286B18  3.916667 0.02625 114.90234
119 US9128286C90  4.000000 0.02500 102.89062
120 US9128286F22  4.000000 0.02500 110.76172
121 US9128286G05  4.000000 0.02375 106.92188
122 US9128286H87  4.000000 0.02375 102.90625
123 US9128286L99  4.083333 0.02250 109.55078
124 US9128286M72  4.083333 0.02250 102.91602
125 US9128286R69  4.166667 0.02250 106.80078
126 US9128286S43  4.166667 0.02375 110.32422
127 US9128286T26  4.250000 0.02375 113.12695
128 US9128286U98  4.250000 0.02125 102.89648
129 US9128286X38  4.250000 0.02125 109.04688
130 US9128286Y11  4.250000 0.01750 102.48047
131 US9128286Z85  4.333333 0.01750 105.30469
132 US9128287B09  4.333333 0.01875 107.73438
133 US9128287C81  4.416667 0.01750 102.60547
134 US912828B667  4.416667 0.02750 108.07812
135 US912828D564  4.500000 0.02375 107.76562
136 US912828G385  4.500000 0.02250 107.68359
137 US912828G534  4.500000 0.01875 101.78320
138 US912828G872  4.583333 0.02125 102.19531
139 US912828H862  4.583333 0.01500 101.62500
140 US912828J272  4.666667 0.02000 107.00391
141 US912828J439  4.666667 0.01750 102.02930
142 US912828J769  4.750000 0.01750 102.16992
143 US912828K742  4.750000 0.02000 107.61328
144 US912828L245  4.750000 0.01875 103.00586
145 US912828L575  4.750000 0.01750 102.91992
146 US912828M490  4.833333 0.01875 103.28906
147 US912828M565  4.833333 0.02250 109.10547
148 US912828M805  4.916667 0.02000 103.67578
149 US912828N308  4.916667 0.02125 104.07422
150 US912828P386  5.000000 0.01750 103.42969
151 US912828P469  5.000000 0.01625 106.17969
152 US912828P790  5.083333 0.01500 102.96484
153 US912828Q293  5.166667 0.01500 103.08594
154 US912828R283  5.250000 0.01625 103.48047
155 US912828R366  5.250000 0.01625 106.29297
156 US912828R697  5.250000 0.01625 103.58984
157 US912828S356  5.333333 0.01375 103.05859
158 US912828S927  5.416667 0.01250 102.81250
159 US912828SF82  5.500000 0.02000 102.30078
160 US912828SV33  5.500000 0.01750 102.35156
161 US912828T263  5.583333 0.01375 103.31641
162 US912828T917  5.666667 0.01625 104.12500
163 US912828TJ95  5.750000 0.01625 102.52734
164 US912828TY62  5.750000 0.01625 102.86523
165 US912828U246  5.750000 0.02000 108.66797
166 US912828U576  5.833333 0.02125 105.73828
167 US912828U659  5.916667 0.01750 101.65820
168 US912828U816  6.000000 0.02000 102.05078
169 US912828UN88  6.000000 0.02000 104.02734
170 US912828V236  6.000000 0.02250 106.25000
171 US912828V723  6.083333 0.01875 102.06250
172 US912828V806  6.166667 0.02250 106.39844
173 US912828V988  6.250000 0.02250 110.39844
174 US912828VB32  6.250000 0.01750 103.83984
175 US912828VS66  6.250000 0.02500 106.25391
176 US912828W481  6.333333 0.02125 106.10938
177 US912828W556  6.416667 0.01875 102.20117
178 US912828W713  6.500000 0.02125 106.24609
179 US912828W895  6.500000 0.01875 102.32812
180 US912828WE61  6.583333 0.02750 107.50781
181 US912828WJ58  6.666667 0.02500 107.73828
182 US912828WZ90  6.750000 0.01750 102.29297
183 US912828X471  6.750000 0.01875 102.46875
184 US912828X703  6.750000 0.02000 105.95703
185 US912828X885  6.833333 0.02375 111.41797
186 US912828XB14  6.916667 0.02125 107.87109
187 US912828XD79  7.000000 0.01875 102.60547
188 US912828XG01  7.000000 0.02125 103.13281
189 US912828XQ82  7.250000 0.02000 103.08594
190 US912828XR65  7.500000 0.01750 102.42188
191 US912828XT22  7.750000 0.02000 106.07031
192 US912828XW50  7.750000 0.01750 102.54297
193 US912828XX34  8.000000 0.02000 106.20312
194 US912828XZ81  8.000000 0.02750 110.88281
195 US912828Y610  8.250000 0.02750 106.81250
196 US912828Y792  8.250000 0.02875 111.62500
197 US912828Y875  8.500000 0.01750 105.39062
198 US912828Y958  8.750000 0.01875 107.77734
199 US912828YA22  8.750000 0.01500 102.30469
200 US912828YB05  9.000000 0.01625 107.08203
201 US912828YD60  9.250000 0.01375 104.97656
202 US912828YE44  9.500000 0.01250 103.60156
203 US912828YF19  9.500000 0.01500 102.40234
204 US912828YG91  9.750000 0.01625 106.42969
205 US912828YH74 10.000000 0.01500 104.61328
206 US912828YK04 10.250000 0.01375 102.27344
207 US912828YM69 15.250000 0.01500 104.68359
208 US912828YQ73 16.250000 0.01625 106.45312
209 US912828YS30 16.500000 0.01750 108.24219
210 US912828YT13 17.250000 0.01500 101.40625
211 US912828YU85 17.500000 0.01625 106.48438
212 US912828YV68 18.250000 0.01500 104.74609
213 US912828YW42 18.500000 0.01625 102.98047
214 US912828YX25 18.750000 0.01750 107.28125
215 US912828YY08 19.000000 0.01750 105.83984
216 US912828YZ72 19.250000 0.01625 101.64648
217 US912828Z294 19.500000 0.01500 102.82422
218 US912828Z526 19.500000 0.01375 104.35547
219 US912828Z609 19.750000 0.01375 101.47461
220 US912828Z781 19.750000 0.01500 105.76953
221 US912828Z864 20.000000 0.01375 102.64453
222 US912828Z948 20.250000 0.01500 105.96484
223 US912828ZA13 20.500000 0.01125 101.25586
224 US912828ZB95 20.750000 0.01125 103.46094
225 US912828ZC78 21.000000 0.01125 103.36328
226 US912828ZD51 21.250000 0.00500 100.73047
227 US912828ZE35 21.500000 0.00625 100.31250
228 US912828ZF00 21.750000 0.00500 100.69141
229 US912828ZG82 22.000000 0.00375 100.32031
230 US912828ZH65 22.250000 0.00250 100.16016
231 US912828ZL77 22.500000 0.00375 100.12109
232 US912828ZM50 22.750000 0.00125  99.98828
233 US912828ZN34 23.000000 0.00500  99.44531
234 US912828ZP81 23.250000 0.00125  99.84766
235 US912828ZQ64 23.500000 0.00625  97.91406
236 US912828ZR48 23.750000 0.00125  99.97656
237 US912828ZS21 24.000000 0.00500  99.36719
238 US912828ZT04 24.250000 0.00250  99.56250
239 US912828ZU76 24.500000 0.00250 100.14062
240 US912828ZV59 24.750000 0.00500  99.30078
241 US912828ZW33 25.000000 0.00250  99.48828
242 US912828ZX16 25.250000 0.00125  99.96094
243 US912828ZY98 25.500000 0.00125  99.80859
244 US91282CAB72 25.750000 0.00250  99.44922
245 US91282CAC55 26.000000 0.00125  99.94727
246 US91282CAD39 26.250000 0.00375  98.42969
247 US91282CAE12 26.500000 0.00625  97.68359
248 US91282CAF86 26.750000 0.00125  99.78906
249 US91282CAG69 27.000000 0.00125  99.93750
250 US91282CAH43 27.250000 0.00500  99.15234
251 US91282CAJ09 27.50000 0.00250   99.40234
252 US91282CAK71 27.75000 0.00125   99.76172
253 US91282CAL54 28.00000 0.00375   98.23828
254 US91282CAM38 28.25000 0.00250   99.35156
255 US91282CAN11 28.50000 0.00125   99.93164
256 US91282CAP68 28.75000 0.00125   99.74219

Donatus answered 25/11, 2020 at 14:4 Comment(3)
Please run dput(df[1:50, ]) and paste the output in the question (then we can run it and see the results)Kao
Edited above to include the full output. Thanks for your help.Donatus
Check your YTM values: I think your years to maturity are all wrong. They don't match the ISIN maturity, coupon & price (for an evaluation date in Nov-2020). Eg. The longest bond in your list: US91282CAW10 does indeed have a 0.25% coupon, and its market price is around 100.097 (yield of +0.21% or so). BUT the maturity is 15-Nov-2023 (ie around 3 years, certainly not 30y). Actually, now I look at it, the ISINs are sorted alphabetically, which probably means by Issue Date (not Maturity Date).Rake
P
3

It has to do with your dateparams. If I run your example with this setup, I get a smooth line:


curveparams <- list(method="ExponentialSplinesFitting", 
                    origDate = Sys.Date())

dateparams <- list(settlementDays=0, period="Semiannual", 
                   dayCounter="ActualActual", 
                   businessDayConvention ="Unadjusted")

curve <- FittedBondCurve(curveparams = curveparams,
                         lengths = df$YrsToMat,
                         coupons = df$Coupons,
                         marketQuotes = df$Prices,
                         dateparams = dateparams)
z <- zoo::zoo(curve$table$zeroRates, order.by=curve$table$date)
plot(z)

zero-rates

Phenylalanine answered 25/11, 2020 at 14:48 Comment(2)
That's interesting that it smoothed the curve, but why are the rates negative? The inputs were all positive yield. Also, Treasuries settle T+1 and the convention is Actual/Actual with Modified Following, so is there a way to keep the conventions in the build and still generate a smooth curve?Donatus
I think that is just QL failing to fit the curve, and setting Kappa = 0.0. The US Treasury curve has inflection points.Rake
R
3

EDIT/ADDED: First off, I'm am not very familiar with the R wrapper for the exponential spline fitting (other than here: R documentation), so my answer is based on my experience with the underlying QuantLib C++ source libraries.

For more description on the spline fit process: https://quant.stackexchange.com/questions/58947/how-many-parameters-in-a-discount-curve-exponential-spline-fit/58962?noredirect=1#comment84675_58962

The bottom line is that I think you will struggle with using R to access the exponential spline fit in the current low-rate environment. Even using the correct data below, while QL will give you a result for the fit, that fit will be fairly useless (see 'Default' in chart). So I would suggest trying one of the other fit methods, if you can only use the current R wrapper.

The problem is that most yield-curve analytics were written before the current era of negative interest rates. The form for the exponential spline discount function uses a parameter, Kappa (in QL speak) that is akin to the far-forward overnight rate. In the "good old days", Kappa would be around 3% (0.03), but now Kappa=0 is a possibility. This will confuse the optimizer as when Kappa=0, all the other parameters (in a constrained fit) are irrelevant, as the discount function is 1 for any time.

If I use the correct input data (below) via the C++ library, using the default settings (which I assume R is doing as the specification does not seem to allow much customization), the curve will fit, but in no way resembles the current Treasury curve. If I inspect the final fit parameters, Kappa=0.000. The way to get around that via C++ or Python is to supply the fit with an initial guess for Kappa which is non-zero (I used 0.01 fwiw). Then you get an OK curve.

These are the par spline yields for the Default (which is what R probably does) and when an initial guess for Kappa is supplied. The latter is clearly much closer to the shape of the Treasury curve (though the 25y-30y sector looks a bit odd).

enter image description here

The other thing that the R-wrapper does not allow you to do is to weight the importance of each bond: hence the oldest, most illiquid bond will have the same influence on the fit as the current on-the-run 10y Note. This is where spline fitting becomes a little esoteric: which bonds should have a higher weight than others? One filter is to remove all bonds entirely if their issue size is below a certain threshold, and/or their coupon is much higher than the average. This will have the happy by-product of speeding things up.

(As an aside, I've submitted a proposed change to the QuantLib custodians for the exponential spline code. If that gets accepted, and the R wrapper is changed to accommodate the extra parameters, then you may have more success with future versions.)

ORIGINAL ANSWER: The original dataset from the question is mixed up, and the YearsToMat does not match the price or coupon on the bonds, so QL will struggle to fit any curve. The correct data should be as below (for prices and YearsToMat for 2-Dec-20, using a rough Actual conversion). I've add the actual maturity date so a different YTM method can be used if needed.

    ISIN            Maturity   YrsToMat Coupons Prices
1   US912828YT13    30-Nov-2021 0.994   0.015   101.379
2   US912828U659    30-Nov-2021 0.994   0.0175  101.629
3   US912828G534    30-Nov-2021 0.994   0.01875 101.746
4   US9128285R78    15-Dec-2021 1.035   0.02625 102.602
5   US912828G872    31-Dec-2021 1.079   0.02125 102.160
6   US912828U816    31-Dec-2021 1.079   0.02    102.027
7   US912828YZ72    31-Dec-2021 1.079   0.01625 101.625
8   US9128285V80    15-Jan-2022 1.120   0.025   102.660
9   US912828H862    31-Jan-2022 1.164   0.015   101.605
10  US912828V723    31-Jan-2022 1.164   0.01875 102.039
11  US912828Z609    31-Jan-2022 1.164   0.01375 101.453
12  US9128286C90    15-Feb-2022 1.205   0.025   102.855
13  US912828SF82    15-Feb-2022 1.205   0.02    102.289
14  US912828ZA13    28-Feb-2022 1.240   0.01125 101.250
15  US912828J439    28-Feb-2022 1.240   0.0175  102.023
16  US912828W556    28-Feb-2022 1.240   0.01875 102.180
17  US9128286H87    15-Mar-2022 1.281   0.02375 102.879
18  US912828J769    31-Mar-2022 1.325   0.0175  102.156
19  US912828W895    31-Mar-2022 1.325   0.01875 102.313
20  US912828ZG82    31-Mar-2022 1.325   0.00375 100.324
21  US9128286M72    15-Apr-2022 1.366   0.0225  102.898
22  US912828WZ90    30-Apr-2022 1.407   0.0175  102.281
23  US912828X471    30-Apr-2022 1.407   0.01875 102.457
24  US912828ZM50    30-Apr-2022 1.407   0.00125 100.000
25  US9128286U98    15-May-2022 1.448   0.02125 102.883
26  US912828SV33    15-May-2022 1.448   0.0175  102.348
27  US912828XR65    31-May-2022 1.492   0.0175  102.410
28  US912828XD79    31-May-2022 1.492   0.01875 102.590
29  US912828ZR48    31-May-2022 1.492   0.00125 99.977
30  US9128286Y11    15-Jun-2022 1.533   0.0175  102.461
31  US912828ZX16    30-Jun-2022 1.574   0.00125 99.973
32  US912828XG01    30-Jun-2022 1.574   0.02125 103.117
33  US912828XW50    30-Jun-2022 1.574   0.0175  102.535
34  US9128287C81    15-Jul-2022 1.615   0.0175  102.594
35  US9128282P40    31-Jul-2022 1.659   0.01875 102.863
36  US912828XQ82    31-Jul-2022 1.659   0.02    103.066
37  US91282CAC55    31-Jul-2022 1.659   0.00125 99.953
38  US912810EM63    15-Aug-2022 1.700   0.0725  112.164
39  US912828TJ95    15-Aug-2022 1.700   0.01625 102.520
40  US912828YA22    15-Aug-2022 1.700   0.015   102.305
41  US9128282S88    31-Aug-2022 1.744   0.01625 102.563
42  US912828L245    31-Aug-2022 1.744   0.01875 102.996
43  US91282CAG69    31-Aug-2022 1.744   0.00125 99.945
44  US912828YF19    15-Sep-2022 1.785   0.015   102.395
45  US9128282W90    30-Sep-2022 1.826   0.01875 103.141
46  US91282CAN11    30-Sep-2022 1.826   0.00125 99.945
47  US912828L575    30-Sep-2022 1.826   0.0175  102.922
48  US912828YK04    15-Oct-2022 1.867   0.01375 102.277
49  US912828M490    31-Oct-2022 1.911   0.01875 103.281
50  US9128283C28    31-Oct-2022 1.911   0.02    103.520
51  US91282CAR25    31-Oct-2022 1.911   0.00125 99.934
52  US912810EN47    15-Nov-2022 1.952   0.07625 114.703
53  US912828TY62    15-Nov-2022 1.952   0.01625 102.871
54  US912828M805    30-Nov-2022 1.993   0.02    103.668
55  US912828YW42    15-Dec-2022 2.034   0.01625 102.980
56  US912828N308    31-Dec-2022 2.078   0.02125 104.070
57  US912828Z294    15-Jan-2023 2.119   0.015   102.836
58  US912828P386    31-Jan-2023 2.163   0.0175  103.430
59  US9128283U26    31-Jan-2023 2.163   0.02375 104.766
60  US912810EP94    15-Feb-2023 2.204   0.07125 115.406
61  US912828UN88    15-Feb-2023 2.204   0.02    104.023
62  US912828Z864    15-Feb-2023 2.204   0.01375 102.656
63  US912828P790    28-Feb-2023 2.240   0.015   102.984
64  US9128284A52    28-Feb-2023 2.240   0.02625 105.492
65  US912828ZD51    15-Mar-2023 2.281   0.005   100.742
66  US9128284D91    31-Mar-2023 2.324   0.025   105.406
67  US912828Q293    31-Mar-2023 2.324   0.015   103.086
68  US912828ZH65    15-Apr-2023 2.366   0.0025  100.180
69  US912828R283    30-Apr-2023 2.407   0.01625 103.484
70  US9128284L18    30-Apr-2023 2.407   0.0275  106.188
71  US912828VB32    15-May-2023 2.448   0.0175  103.844
72  US912828ZP81    15-May-2023 2.448   0.00125 99.867
73  US9128284S60    31-May-2023 2.491   0.0275  106.383
74  US912828R697    31-May-2023 2.491   0.01625 103.594
75  US912828ZU76    15-Jun-2023 2.533   0.0025  100.156
76  US9128284U17    30-Jun-2023 2.574   0.02625 106.273
77  US912828S356    30-Jun-2023 2.574   0.01375 103.063
78  US912828ZY98    15-Jul-2023 2.615   0.00125 99.820
79  US912828S927    31-Jul-2023 2.658   0.0125  102.813
80  US912828Y610    31-Jul-2023 2.658   0.0275  106.797
81  US912828VS66    15-Aug-2023 2.700   0.025   106.250
82  US912810EQ77    15-Aug-2023 2.700   0.0625  116.570
83  US91282CAF86    15-Aug-2023 2.700   0.00125 99.805
84  US9128284X55    31-Aug-2023 2.743   0.0275  106.984
85  US9128282D10    31-Aug-2023 2.743   0.01375 103.242
86  US91282CAK71    15-Sep-2023 2.784   0.00125 99.781
87  US9128285D82    30-Sep-2023 2.825   0.02875 107.547
88  US912828T263    30-Sep-2023 2.825   0.01375 103.328
89  US91282CAP68    15-Oct-2023 2.867   0.00125 99.766
90  US912828T917    31-Oct-2023 2.910   0.01625 104.148
91  US9128285K26    31-Oct-2023 2.910   0.02875 107.758
92  US912828WE61    15-Nov-2023 2.951   0.0275  107.523
93  US91282CAW10    15-Nov-2023 2.951   0.0025  100.117
94  US912828U576    30-Nov-2023 2.992   0.02125 105.742
95  US9128285P13    30-Nov-2023 2.992   0.02875 107.969
96  US9128285U08    31-Dec-2023 3.077   0.02625 107.391
97  US912828V236    31-Dec-2023 3.077   0.0225  106.250
98  US9128285Z94    31-Jan-2024 3.162   0.025   107.180
99  US912828V806    31-Jan-2024 3.162   0.0225  106.398
100 US912828B667    15-Feb-2024 3.203   0.0275  108.070
101 US912828W481    29-Feb-2024 3.242   0.02125 106.125
102 US9128286G05    29-Feb-2024 3.242   0.02375 106.930
103 US912828W713    31-Mar-2024 3.326   0.02125 106.250
104 US912828X703    30-Apr-2024 3.409   0.02    105.961
105 US9128286R69    30-Apr-2024 3.409   0.0225  106.805
106 US912828WJ58    15-May-2024 3.450   0.025   107.734
107 US912828XT22    31-May-2024 3.493   0.02    106.078
108 US9128286Z85    30-Jun-2024 3.576   0.0175  105.313
109 US912828XX34    30-Jun-2024 3.576   0.02    106.195
110 US9128282N91    31-Jul-2024 3.661   0.02125 106.758
111 US912828Y875    31-Jul-2024 3.661   0.0175  105.391
112 US912828D564    15-Aug-2024 3.702   0.02375 107.766
113 US912828YE44    31-Aug-2024 3.745   0.0125  103.602
114 US9128282U35    31-Aug-2024 3.745   0.01875 105.945
115 US9128282Y56    30-Sep-2024 3.828   0.02125 106.984
116 US912828YH74    30-Sep-2024 3.828   0.015   104.602
117 US912828YM69    31-Oct-2024 3.912   0.015   104.672
118 US9128283D01    31-Oct-2024 3.912   0.0225  107.594
119 US912828G385    15-Nov-2024 3.953   0.0225  107.672
120 US912810ES34    15-Nov-2024 3.953   0.075   128.516
121 US9128283J70    30-Nov-2024 3.995   0.02125 107.234
122 US912828YV68    30-Nov-2024 3.995   0.015   104.734
123 US912828YY08    31-Dec-2024 4.079   0.0175  105.813
124 US9128283P31    31-Dec-2024 4.079   0.0225  107.867
125 US9128283V09    31-Jan-2025 4.164   0.025   109.023
126 US912828Z526    31-Jan-2025 4.164   0.01375 104.336
127 US912810ET17    15-Feb-2025 4.205   0.07625 130.727
128 US912828J272    15-Feb-2025 4.205   0.02    106.984
129 US9128283Z13    28-Feb-2025 4.241   0.0275  110.195
130 US912828ZC78    28-Feb-2025 4.241   0.01125 103.320
131 US9128284F40    31-Mar-2025 4.326   0.02625 109.813
132 US912828ZF00    31-Mar-2025 4.326   0.005   100.664
133 US912828ZL77    30-Apr-2025 4.408   0.00375 100.094
134 US9128284M90    30-Apr-2025 4.408   0.02875 111.070
135 US912828XB14    15-May-2025 4.449   0.02125 107.828
136 US912828ZT04    31-May-2025 4.493   0.0025  99.500
137 US9128284R87    31-May-2025 4.493   0.02875 111.227
138 US912828XZ81    30-Jun-2025 4.575   0.0275  110.797
139 US912828ZW33    30-Jun-2025 4.575   0.0025  99.445
140 US912828Y792    31-Jul-2025 4.660   0.02875 111.547
141 US91282CAB72    31-Jul-2025 4.660   0.0025  99.398
142 US912810EV62    15-Aug-2025 4.701   0.06875 130.453
143 US912828K742    15-Aug-2025 4.701   0.02    107.563
144 US91282CAJ09    31-Aug-2025 4.745   0.0025  99.359
145 US9128284Z04    31-Aug-2025 4.745   0.0275  111.125
146 US91282CAM38    30-Sep-2025 4.827   0.0025  99.305
147 US9128285C00    30-Sep-2025 4.827   0.03    112.477
148 US91282CAT80    31-Oct-2025 4.912   0.0025  99.266
149 US9128285J52    31-Oct-2025 4.912   0.03    112.633
150 US912828M565    15-Nov-2025 4.953   0.0225  109.047
151 US9128285N64    30-Nov-2025 4.994   0.02875 112.188
152 US9128285T35    31-Dec-2025 5.079   0.02625 111.094
153 US9128286A35    31-Jan-2026 5.164   0.02625 111.234
154 US912828P469    15-Feb-2026 5.205   0.01625 106.141
155 US912810EW46    15-Feb-2026 5.205   0.06    128.820
156 US9128286F22    28-Feb-2026 5.240   0.025   110.688
157 US9128286L99    31-Mar-2026 5.325   0.0225  109.484
158 US9128286S43    30-Apr-2026 5.407   0.02375 110.242
159 US912828R366    15-May-2026 5.448   0.01625 106.227
160 US9128286X38    31-May-2026 5.492   0.02125 108.969
161 US9128287B09    30-Jun-2026 5.574   0.01875 107.656
162 US912828Y958    31-Jul-2026 5.659   0.01875 107.711
163 US9128282A70    15-Aug-2026 5.700   0.015   105.625
164 US912810EX29    15-Aug-2026 5.700   0.0675  135.375
165 US912828YD60    31-Aug-2026 5.744   0.01375 104.906
166 US912828YG91    30-Sep-2026 5.826   0.01625 106.344
167 US912828YQ73    31-Oct-2026 5.911   0.01625 106.375
168 US912810EY02    15-Nov-2026 5.952   0.065   135.305
169 US912828U246    15-Nov-2026 5.952   0.02    108.602
170 US912828YU85    30-Nov-2026 5.993   0.01625 106.414
171 US912828YX25    31-Dec-2026 6.078   0.0175  107.211
172 US912828Z781    31-Jan-2027 6.163   0.015   105.695
173 US912810EZ76    15-Feb-2027 6.204   0.06625 137.297
174 US912828V988    15-Feb-2027 6.204   0.0225  110.297
175 US912828ZB95    28-Feb-2027 6.240   0.01125 103.383
176 US912828ZE35    31-Mar-2027 6.324   0.00625 100.250
177 US912828ZN34    30-Apr-2027 6.407   0.005   99.391
178 US912828X885    15-May-2027 6.448   0.02375 111.313
179 US912828ZS21    31-May-2027 6.491   0.005   99.313
180 US912828ZV59    30-Jun-2027 6.574   0.005   99.234
181 US91282CAD39    31-Jul-2027 6.658   0.00375 98.359
182 US9128282R06    15-Aug-2027 6.700   0.0225  110.656
183 US912810FA17    15-Aug-2027 6.700   0.06375 138.109
184 US91282CAH43    31-Aug-2027 6.743   0.005   99.063
185 US91282CAL54    30-Sep-2027 6.825   0.00375 98.125
186 US91282CAU53    31-Oct-2027 6.910   0.005   98.875
187 US9128283F58    15-Nov-2027 6.951   0.0225  110.844
188 US912810FB99    15-Nov-2027 6.951   0.06125 137.703
189 US9128283W81    15-Feb-2028 7.203   0.0275  114.563
190 US9128284N73    15-May-2028 7.450   0.02875 115.750
191 US912810FE39    15-Aug-2028 7.702   0.055   136.156
192 US9128284V99    15-Aug-2028 7.702   0.02875 116.047
193 US912810FF04    15-Nov-2028 7.953   0.0525  135.156
194 US9128285M81    15-Nov-2028 7.953   0.03125 118.297
195 US9128286B18    15-Feb-2029 8.205   0.02625 114.656
196 US912810FG86    15-Feb-2029 8.205   0.0525  136.063
197 US9128286T26    15-May-2029 8.449   0.02375 112.859
198 US912828YB05    15-Aug-2029 8.701   0.01625 106.813
199 US912810FJ26    15-Aug-2029 8.701   0.06125 145.344
200 US912828YS30    15-Nov-2029 8.953   0.0175  107.969
201 US912828Z948    15-Feb-2030 9.205   0.015   105.688
202 US912810FM54    15-May-2030 9.448   0.0625  149.531
203 US912828ZQ64    15-May-2030 9.448   0.00625 97.641
204 US91282CAE12    15-Aug-2030 9.700   0.00625 97.391
205 US91282CAV37    15-Nov-2030 9.952   0.00875 99.609
206 US912810FP85    15-Feb-2031 10.204  0.05375 144.203
207 US912810FT08    15-Feb-2036 15.203  0.045   147.125
208 US912810PT97    15-Feb-2037 16.205  0.0475  152.891
209 US912810PU60    15-May-2037 16.449  0.05    157.219
210 US912810PW27    15-Feb-2038 17.205  0.04375 149.078
211 US912810PX00    15-May-2038 17.448  0.045   151.516
212 US912810QA97    15-Feb-2039 18.204  0.035   136.203
213 US912810QB70    15-May-2039 18.448  0.0425  148.813
214 US912810QC53    15-Aug-2039 18.700  0.045   153.375
215 US912810QD37    15-Nov-2039 18.951  0.04375 151.641
216 US912810QE10    15-Feb-2040 19.203  0.04625 156.375
217 US912810QH41    15-May-2040 19.450  0.04375 152.281
218 US912810SR05    15-May-2040 19.450  0.01125 94.891
219 US912810QK79    15-Aug-2040 19.702  0.03875 143.609
220 US912810SQ22    15-Aug-2040 19.702  0.01125 94.609
221 US912810QL52    15-Nov-2040 19.953  0.0425  150.609
222 US912810QN19    15-Feb-2041 20.205  0.0475  160.172
223 US912810QQ40    15-May-2041 20.449  0.04375 153.625
224 US912810QS06    15-Aug-2041 20.701  0.0375  142.328
225 US912810QT88    15-Nov-2041 20.953  0.03125 130.953
226 US912810QU51    15-Feb-2042 21.205  0.03125 131.234
227 US912810QW18    15-May-2042 21.448  0.03    128.766
228 US912810QX90    15-Aug-2042 21.700  0.0275  124.047
229 US912810QY73    15-Nov-2042 21.952  0.0275  123.938
230 US912810QZ49    15-Feb-2043 22.204  0.03125 131.281
231 US912810RB61    15-May-2043 22.448  0.02875 126.438
232 US912810RC45    15-Aug-2043 22.700  0.03625 141.281
233 US912810RD28    15-Nov-2043 22.951  0.0375  143.938
234 US912810RE01    15-Feb-2044 23.203  0.03625 141.578
235 US912810RG58    15-May-2044 23.450  0.03375 136.766
236 US912810RH32    15-Aug-2044 23.702  0.03125 131.797
237 US912810RJ97    15-Nov-2044 23.953  0.03    129.313
238 US912810RK60    15-Feb-2045 24.205  0.025   119.078
239 US912810RM27    15-May-2045 24.449  0.03    129.578
240 US912810RN00    15-Aug-2045 24.701  0.02875 127.063
241 US912810RP57    15-Nov-2045 24.953  0.03    129.891
242 US912810RQ31    15-Feb-2046 25.205  0.025   119.281
243 US912810RS96    15-May-2046 25.448  0.025   119.313
244 US912810RT79    15-Aug-2046 25.700  0.0225  113.922
245 US912810RU43    15-Nov-2046 25.952  0.02875 127.563
246 US912810RV26    15-Feb-2047 26.204  0.03    130.563
247 US912810RX81    15-May-2047 26.448  0.03    130.703
248 US912810RY64    15-Aug-2047 26.700  0.0275  125.188
249 US912810RZ30    15-Nov-2047 26.951  0.0275  125.328
250 US912810SA79    15-Feb-2048 27.203  0.03    131.063
251 US912810SC36    15-May-2048 27.450  0.03125 134.047
252 US912810SD19    15-Aug-2048 27.702  0.03    131.359
253 US912810SE91    15-Nov-2048 27.953  0.03375 140.313
254 US912810SF66    15-Feb-2049 28.205  0.03    131.719
255 US912810SH23    15-May-2049 28.449  0.02875 128.906
256 US912810SJ88    15-Aug-2049 28.701  0.0225  114.281
257 US912810SK51    15-Nov-2049 28.953  0.02375 117.297
258 US912810SL35    15-Feb-2050 29.205  0.02    108.453
259 US912810SN90    15-May-2050 29.448  0.0125  90.516
260 US912810SP49    15-Aug-2050 29.700  0.01375 93.391
261 US912810SS87    15-Nov-2050 29.952  0.01625 99.359
Rake answered 2/12, 2020 at 12:48 Comment(2)
you are certainly right that my original df did not copy in correctly - apologies on that. I'm currently trying to use your corrected df, but when I go to fit the curve, I receive the following message "Error in fittedBondCurveEngine(curveparams, lengths, coupons, marketQuotes, : effective date (December 2nd, 2020) later than or equal to termination date (December 2nd, 2020)". Apologies if that's an easy fix - QuantLib beginner. Thank you!Donatus
@Donatus I've updated my answer above. The error you mention looks like you are still feeding the method incorrect data: are you inadvertently passing a bond with a maturity of zero years?Rake

© 2022 - 2024 — McMap. All rights reserved.