Skip to content

Instantly share code, notes, and snippets.

@tomwhoiscontrary
Last active July 25, 2018 14:37
Show Gist options
  • Save tomwhoiscontrary/ee550ba2f0423e149b78a0c36e7c679f to your computer and use it in GitHub Desktop.
Save tomwhoiscontrary/ee550ba2f0423e149b78a0c36e7c679f to your computer and use it in GitHub Desktop.
Another demonstration that not all is right with the convex monotone implementation in QuantLib - https://imgur.com/a/ksS7OD8
term rate forward
0.0 -0.0033133321508 -0.0033133321508
0.1 -0.00329678287008599 -0.003263684308657968
0.2 -0.003247135027943958 -0.0031147407822318712
0.30000000000000004 -0.0031652069127224678 -0.00289212724033709
0.4 -0.00307524118684741 -0.002711931672110584
0.5 -0.0029812451740789943 -0.002491961467903277
0.6 -0.002878499729047622 -0.0022396014243447277
0.7 -0.0027726330307377965 -0.002047717424672988
0.7999999999999999 -0.002674128906090226 -0.0019474822563351547
0.8999999999999999 -0.002593390389450774 -0.0019474822563351547
0.9999999999999999 -0.0025136408168061064 -0.0013503925761523816
1.0999999999999999 -0.00233154165440122 1.444638714210994E-4
1.2 -0.0020901139922760467 8.950576348648737E-4
1.3 -0.0018488212723908584 0.0012266486464327583
1.4000000000000001 -0.0015788476101468245 0.0025890082308638387
1.5000000000000002 -0.0012632390880575066 0.0036755890907673935
1.6000000000000003 -9.23517565934446E-4 0.004725984130992435
1.7000000000000004 -5.603093016668628E-4 0.005745655521385812
1.8000000000000005 -1.8434830009279093E-4 0.0074555660258681655
1.9000000000000006 2.2945506494619547E-4 0.007681268605719164
2.0000000000000004 6.020457419848433E-4 0.007681268605719164
2.1000000000000005 9.391515926388587E-4 0.007681268605719164
2.2000000000000006 0.0012456114568697818 0.007681268605719164
2.3000000000000007 0.0015254226372545378 0.007681268605719164
2.400000000000001 0.0017819162192738974 0.007681268605719164
2.500000000000001 0.002017890314731708 0.007681268605719164
2.600000000000001 0.002235712556692764 0.007681268605719164
2.700000000000001 0.0024373998177678164 0.007681268605719164
2.800000000000001 0.0026246808459089357 0.007681268605719164
2.9000000000000012 0.0027990459410748058 0.007681268605719164
3.0000000000000013 0.002961786696562952 0.007681268605719164
3.1000000000000014 0.0032174536394507383 0.013500840573787115
3.2000000000000015 0.0035622807157110587 0.014969277485270716
3.3000000000000016 0.003927641624015328 0.016235381793728992
3.4000000000000017 0.004305773596741273 0.01729915349916189
3.5000000000000018 0.004689801039709173 0.01816059260156941
3.600000000000002 0.005073612313648155 0.018819699100951576
3.700000000000002 0.005451756497046367 0.019276472997308336
3.800000000000002 0.005819356449603727 0.01953091429063969
3.900000000000002 0.00617204757510301 0.01958897024100489
4.000000000000002 0.006507470641750557 0.01958897024100489
4.100000000000001 0.006827309882289266 0.01976489229163101
4.200000000000001 0.007140918894709387 0.020226660171787918
4.300000000000001 0.007450245972756648 0.020651081985245505
4.4 0.00775473429225876 0.02103815773200378
4.5 0.008053876524525412 0.021387887412062732
4.6 0.008347209456404589 0.021700271025422373
4.699999999999999 0.008634309297140179 0.021975308572082693
4.799999999999999 0.008914787571872425 0.0222130000520437
4.899999999999999 0.009188287517975019 0.022413345465305386
4.999999999999998 0.009454480913831748 0.02257634481186776
5.099999999999998 0.009713109183525671 0.022722553853041734
5.1999999999999975 0.009965298238127574 0.022933251028775515
5.299999999999997 0.010212055096031998 0.023155497221516587
5.399999999999997 0.01045389541662968 0.023389292431264943
5.4999999999999964 0.010691297356810209 0.02363463665802059
5.599999999999996 0.010924704919399635 0.023891529901783524
5.699999999999996 0.011154530949130952 0.02415997216255375
5.799999999999995 0.011381159818686601 0.02443996344033126
5.899999999999995 0.01160494984158411 0.024731503735116057
5.999999999999995 0.011826235443773177 0.025034593046908145
6.099999999999994 0.012045330998012773 0.0253533252777991
6.199999999999994 0.012263052990507497 0.025729240473265413
6.299999999999994 0.012479562304709466 0.02607141578289081
6.399999999999993 0.012694388599197387 0.02637985120667523
6.499999999999993 0.012907090476637436 0.026654546744618743
6.5999999999999925 0.013117253291049341 0.026895502396721324
6.699999999999992 0.01332448715143675 0.027102718162982972
6.799999999999992 0.013528425101567777 0.027276194043403645
6.8999999999999915 0.013728721458035591 0.027415930037983413
6.999999999999991 0.013925050290770886 0.027521926146722248
7.099999999999991 0.014117104031961784 0.02759418236962015
7.19999999999999 0.01431494422302727 0.02844955975145346
7.29999999999999 0.014508569093279685 0.02844955975145346
7.39999999999999 0.014696960858930682 0.02844955975145346
7.499999999999989 0.014880328844164318 0.02844955975145346
7.599999999999989 0.015058871356102333 0.02844955975145346
7.699999999999989 0.015232776400197802 0.02844955975145346
7.799999999999988 0.015402222340598513 0.02844955975145346
7.899999999999988 0.015567378510356174 0.02844955975145346
7.999999999999988 0.015728405775869887 0.02844955975145346
8.099999999999987 0.015885457059519065 0.02844955975145346
8.199999999999987 0.016038677824054853 0.02844955975145346
8.299999999999986 0.016188206521975317 0.02844955975145346
8.399999999999986 0.01633417501280244 0.02844955975145346
8.499999999999986 0.016476708950904213 0.02844955975145346
8.599999999999985 0.01661592814625944 0.02844955975145346
8.699999999999985 0.016751946900342124 0.02844955975145346
8.799999999999985 0.016884874319104758 0.02844955975145346
8.899999999999984 0.017014814604861483 0.02844955975145346
8.999999999999984 0.017141867328712503 0.02844955975145346
9.099999999999984 0.017266127685006363 0.02844955975145346
9.199999999999983 0.01739326324749987 0.02936159748509809
9.299999999999983 0.017523563390820646 0.029652329123110888
9.399999999999983 0.017653915148162783 0.029892501494398066
9.499999999999982 0.01778378468680219 0.030082114598959736
9.599999999999982 0.017912660417044927 0.03022116843679573
9.699999999999982 0.018040051845679285 0.03030966300790619
9.799999999999981 0.018165488499624658 0.030347598312291058
9.89999999999998 0.01828829513435234 0.030246320220416845
9.99999999999998 0.018405893254908164 0.02978888787594003
10.09999999999998 0.018514821598868726 0.028965417830398632
10.19999999999998 0.0186124671466183 0.028102768952412926
10.29999999999998 0.018701860101766252 0.02754530767435892
10.399999999999979 0.01878441011009519 0.027037007834650517
10.499999999999979 0.01886078088854609 0.02657786943328766
10.599999999999978 0.018931611108137642 0.02616789247027035
10.699999999999978 0.01899751556433641 0.02580707694559864
10.799999999999978 0.019059086282406507 0.025495422859272587
10.899999999999977 0.019116893561914275 0.025232930211292137
10.999999999999977 0.01917148696426002 0.025019599001657233
11.099999999999977 0.019223396246829602 0.024855429230367987
11.199999999999976 0.019273132247102264 0.024740420897424287
11.299999999999976 0.019321187719814604 0.02467457400282619
11.399999999999975 0.019368037832352584 0.024657254562106573
11.499999999999975 0.019414031021306965 0.024657254562106573
11.599999999999975 0.019459231224244894 0.024657254562106573
11.699999999999974 0.019503658774141147 0.024657254562106573
11.799999999999974 0.019547333314717127 0.024657254562106573
11.899999999999974 0.01959027382940107 0.024657254562106573
11.999999999999973 0.019632498668840283 0.024657254562106573
12.099999999999973 0.019674025577049094 0.024657254562106573
12.199999999999973 0.019714871716270878 0.024657254562106573
12.299999999999972 0.019755049898510332 0.024655294990272733
12.399999999999972 0.01979453554294482 0.024645963635326895
12.499999999999972 0.019833284022440625 0.024628946333340715
12.599999999999971 0.019871251888964225 0.02460424308431417
12.69999999999997 0.01990839706292409 0.024571853888247258
12.79999999999997 0.019944678779715938 0.024531778745139995
12.89999999999997 0.01998005753875421 0.02448401765499235
12.99999999999997 0.020014495054855985 0.024428570617804346
13.09999999999997 0.020047954211851564 0.024365437633576
13.199999999999969 0.020080399018303663 0.024294618702307258
13.299999999999969 0.020111794565224227 0.024216113823998187
13.399999999999968 0.020142106985684572 0.02412992299864873
13.499999999999968 0.020171303416220542 0.024036046226258934
13.599999999999968 0.020199351959940465 0.023934483506828752
13.699999999999967 0.020226221651248787 0.0238252348403582
13.799999999999967 0.020251882422103427 0.023708300226847293
13.899999999999967 0.020276305069729727 0.023583679666296056
13.999999999999966 0.020299461225717994 0.023451373158704422
14.099999999999966 0.020321323326436127 0.023311380704072432
14.199999999999966 0.02034186458469237 0.0231637023024001
14.299999999999965 0.020361058962587046 0.023008337953687383
14.399999999999965 0.02037888114549545 0.022845287657934296
14.499999999999964 0.02039530651712737 0.02267455141514088
14.599999999999964 0.020410311135611505 0.022496129225307082
14.699999999999964 0.020423871710556034 0.022310021088432913
14.799999999999963 0.020435965581039182 0.0221162270045184
14.899999999999963 0.020446570694486084 0.021914746973563506
14.999999999999963 0.020455665586390528 0.021705580995568255
15.099999999999962 0.020463229360842494 0.021488729070532633
15.199999999999962 0.020469241671824324 0.02126419119845667
15.299999999999962 0.020473908504477712 0.021124572619744417
15.399999999999961 0.020477771469951226 0.021012608588921237
15.499999999999961 0.020480853935681716 0.020898069561299207
15.59999999999996 0.02048315440488988 0.02078095553687833
15.69999999999996 0.02048467141893093 0.020661266515658604
15.79999999999996 0.020485403556087797 0.020539002497640034
15.89999999999996 0.020485349430409878 0.02041416348282262
15.99999999999996 0.020484507690595323 0.020286749471206365
16.09999999999996 0.020482877018915012 0.020156760462791266
16.19999999999996 0.02048045613017634 0.020024196457577317
16.29999999999996 0.020477243770725184 0.019889057455564525
16.399999999999963 0.020473238717484327 0.01975134345675289
16.499999999999964 0.020468439777026937 0.019611054461142412
16.599999999999966 0.020462845784683426 0.019468190468733076
16.699999999999967 0.020456455603680507 0.019322751479524905
16.79999999999997 0.020449268124310905 0.019174737493517884
16.89999999999997 0.02044128226313263 0.01902414851071202
16.99999999999997 0.02043249696219641 0.01887098453110731
17.099999999999973 0.020422911188300363 0.018715245554703767
17.199999999999974 0.02041252393227053 0.018556931581501367
17.299999999999976 0.020401334208266463 0.018396042611500123
17.399999999999977 0.020389341053110722 0.018232578644700036
17.49999999999998 0.020376543525641326 0.0180665396811011
17.59999999999998 0.02036294070608637 0.01789792572070332
17.69999999999998 0.020348531695459735 0.017726736763506702
17.799999999999983 0.020333315614977233 0.017552972809511236
17.899999999999984 0.02031729160549234 0.01737663385871692
17.999999999999986 0.02030045882695064 0.017197719911123767
18.099999999999987 0.020282816457862486 0.017016230966731757
18.19999999999999 0.020264363694792925 0.01683216702554091
18.29999999999999 0.020245099751868445 0.016645528087551223
18.39999999999999 0.020225023860299722 0.01645631415276269
18.499999999999993 0.020204135267919917 0.01626452522117531
18.599999999999994 0.02018243323873781 0.016070161292789077
18.699999999999996 0.020159917052505326 0.01587322236760401
18.799999999999997 0.020136586004298802 0.01567370844562009
18.9 0.020112439404113596 0.01547161952683733
19.0 0.02008747657647149 0.015266955611255718
19.1 0.02006169686004039 0.015059716698875271
19.200000000000003 0.020035099607265974 0.014849902789695973
19.300000000000004 0.020007684184014718 0.014637513883717833
19.400000000000006 0.019979449969228024 0.014422549980940842
19.500000000000007 0.019950396354586956 0.014205011081365009
19.60000000000001 0.019920522744187243 0.013984897184990339
19.70000000000001 0.01988982855422421 0.013762208291816819
19.80000000000001 0.019858313212687207 0.013536944401844449
19.900000000000013 0.01982597615906328 0.013309105515073243
20.000000000000014 0.019792816844049734 0.013078691631503186
20.100000000000016 0.019758834729275282 0.01284570275113428
20.200000000000017 0.01972402928702945 0.012610138873966531
20.30000000000002 0.019688399999999995 0.012372000000006267
20.40000000000002 0.019643452620019847 0.008961683532540121
20.50000000000002 0.019586631200946027 0.007323854451669831
20.600000000000023 0.019526439027199197 0.007164576727384348
20.700000000000024 0.019466720801099673 0.007165025187784316
20.800000000000026 0.019407579946685346 0.007165890444030314
20.900000000000027 0.019349010170562873 0.007167172496122337
21.00000000000003 0.01929100529921307 0.007168871344060388
21.10000000000003 0.019233559276150287 0.007170986987844467
21.20000000000003 0.01917666615916218 0.007173519427474569
21.300000000000033 0.019120320117627265 0.007176468662950703
21.400000000000034 0.019064515429907627 0.007179834694272861
21.500000000000036 0.019009246480814427 0.007183617521441046
21.600000000000037 0.01895450775914381 0.007187817144455259
21.70000000000004 0.01890029385528092 0.0071924335633155
21.80000000000004 0.01884659945886992 0.007197466778021766
21.90000000000004 0.01879341935654773 0.00720291678857406
22.000000000000043 0.018740748429739718 0.007208783594972382
22.100000000000044 0.01868858165251514 0.007215067197216729
22.200000000000045 0.018636914089500543 0.007221767595307104
22.300000000000047 0.018585740893849362 0.007228884789243507
22.40000000000005 0.018535057305265876 0.0072364187790259354
22.50000000000005 0.018484858648081817 0.0072443695646543915
22.60000000000005 0.018435140329384127 0.007252737146128875
22.700000000000053 0.018385897837192137 0.0072615215234493845
22.800000000000054 0.018337126738682718 0.007270722696615923
22.900000000000055 0.018288822678461984 0.007280340665628488
23.000000000000057 0.018240981376882025 0.00729037543048708
23.10000000000006 0.018193598628401378 0.007300826991191698
23.20000000000006 0.01814667029998792 0.007311695347742338
23.30000000000006 0.018100192329562878 0.007322980500139012
23.400000000000063 0.018054160724484715 0.007334682448381712
23.500000000000064 0.018008571560071754 0.007346801192470437
23.600000000000065 0.017963420978162344 0.007359336732405193
23.700000000000067 0.01791870518571148 0.007372289068185973
23.800000000000068 0.01787442045342283 0.007385658199812781
23.90000000000007 0.017830563114415044 0.007399444127285616
24.00000000000007 0.017787129562921472 0.007413646850604479
24.100000000000072 0.017744116253022208 0.007428266369769367
24.200000000000074 0.017701519697407606 0.007443302684780283
24.300000000000075 0.01765933646617227 0.0074587557956372254
24.400000000000077 0.017617563185638785 0.007474625702340197
24.500000000000078 0.017576196537210168 0.007490912404889194
24.60000000000008 0.017535233256250365 0.007507615903284219
24.70000000000008 0.017494670130991933 0.007524736197525269
24.800000000000082 0.01745450400147012 0.007542273287612346
24.900000000000084 0.017414731758482654 0.007560227173545453
25.000000000000085 0.017375350342574515 0.007578597855324585
25.100000000000087 0.017336356743046927 0.007597385332949742
25.200000000000088 0.017297747996989986 0.007616589606420929
25.30000000000009 0.017259521188338216 0.007636210675738145
25.40000000000009 0.017221670964566897 0.007651199999999991
25.500000000000092 0.01718413970588232 0.007651199999999991
25.600000000000094 0.017146901660156214 0.007651199999999991
25.700000000000095 0.017109953404669226 0.007651199999999991
25.800000000000097 0.017073291569767408 0.007651199999999991
25.900000000000098 0.0170369128378378 0.007651199999999991
26.0000000000001 0.017000813942307656 0.007651199999999991
26.1000000000001 0.01696499166666663 0.007651199999999991
26.200000000000102 0.016929442843511413 0.007651199999999991
26.300000000000104 0.016894164353612132 0.007651199999999991
26.400000000000105 0.01685915312499996 0.007651199999999991
26.500000000000107 0.016824406132075434 0.007651199999999991
26.600000000000108 0.016789920394736806 0.007651199999999991
26.70000000000011 0.01675569297752805 0.007651199999999991
26.80000000000011 0.016721720988805932 0.007651199999999991
26.900000000000112 0.01668800157992561 0.007651199999999991
27.000000000000114 0.01665453194444441 0.007651199999999991
27.100000000000115 0.016621309317343135 0.007651199999999991
27.200000000000117 0.016588330974264667 0.007651199999999991
27.300000000000118 0.016555594230769192 0.007651199999999991
27.40000000000012 0.0165230964416058 0.007651199999999991
27.50000000000012 0.01649083499999996 0.007651199999999991
27.600000000000122 0.016458807336956482 0.007651199999999991
27.700000000000124 0.016427010968366615 0.007651340804073592
27.800000000000125 0.016395447727665248 0.0076541093214670675
27.900000000000126 0.016364127014043082 0.007660417951464021
28.000000000000128 0.016333058872255002 0.007670266694064426
28.10000000000013 0.016302253204070048 0.0076836555492683645
28.20000000000013 0.016271719770806638 0.007700584517075809
28.300000000000132 0.016241468195814027 0.007721053597486649
28.400000000000134 0.01621150796690134 0.0077450627905010505
28.500000000000135 0.01618184843871546 0.007772612096118903
28.600000000000136 0.016152498835069067 0.007803701514340261
28.700000000000138 0.016123468251219936 0.007838331045165126
28.80000000000014 0.016094765656102836 0.00787650068859344
28.90000000000014 0.016066399894515023 0.007918210444625262
29.000000000000142 0.016038379689256557 0.007963460313260562
29.100000000000144 0.016010713643226454 0.008012250294499368
29.200000000000145 0.015983410241475808 0.00806458038834168
29.300000000000146 0.015956477853218826 0.008120450594787387
29.400000000000148 0.015929924733802874 0.008179860913836684
29.50000000000015 0.015903759026638382 0.008242811345489376
29.60000000000015 0.015877988765089723 0.008309301889745657
29.700000000000152 0.015852621874327774 0.00837933254660539
29.800000000000153 0.01582766617314531 0.008452903316068572
29.900000000000155 0.015803129375735858 0.008530014198135288
30.000000000000156 0.015779019093437024 0.008610665192805428
30.100000000000158 0.015755342836439094 0.008694856300079101
30.20000000000016 0.015732108015459604 0.00878258751995628
30.30000000000016 0.01570932194338486 0.008873858852436883
30.400000000000162 0.015686991836878977 0.008968670297521047
30.500000000000163 0.015665134844980576 0.009079015139259045
30.600000000000165 0.015643810814417253 0.009200579146732696
30.700000000000166 0.015623018073661604 0.00931993095891917
30.800000000000168 0.015602744265360676 0.009437070575818413
30.90000000000017 0.015582977192127251 0.009551997997430423
31.00000000000017 0.015563704813959746 0.0096647132237552
31.100000000000172 0.015544915245711903 0.009775216254792801
31.200000000000173 0.015526596754611145 0.00988350709054317
31.300000000000175 0.015508737757824468 0.009989585731006306
31.400000000000176 0.015491326820070891 0.010093452176182238
31.500000000000178 0.015474352651279345 0.010195106426070966
31.60000000000018 0.015457804104291057 0.010294548480672405
31.70000000000018 0.015441670172605393 0.010391778339986696
31.800000000000182 0.015425939988168293 0.010486796004013754
31.900000000000183 0.015410602819202219 0.010579601472753608
32.000000000000185 0.015395648068076861 0.010670194746206257
32.100000000000186 0.0153810652692196 0.010758575824371591
32.20000000000019 0.015366844087064936 0.010844744707249804
32.30000000000019 0.015352974314041989 0.010928701394840784
32.40000000000019 0.015339445868599266 0.011010445887144532
32.50000000000019 0.015326248793265912 0.011089978184160992
32.60000000000019 0.015313373252748633 0.011167298285890331
32.700000000000195 0.01530080953206353 0.011242406192332438
32.800000000000196 0.015288548034702107 0.011315301903487313
32.9000000000002 0.015276579280830755 0.011385985419354983
33.0000000000002 0.015264893905522943 0.011454456739935365
33.1000000000002 0.015253482657023447 0.011520715865228598
33.2000000000002 0.015242336395043974 0.011584762795234627
33.3000000000002 0.015231446089089492 0.011646597529953423
33.400000000000205 0.0152208028168146 0.01170622006938496
33.500000000000206 0.015210397762409376 0.011763630413529291
33.60000000000021 0.01520022221501401 0.011818828562386446
33.70000000000021 0.015190267567161679 0.01187181451595637
33.80000000000021 0.015180525313249083 0.011922588274239088
33.90000000000021 0.015170987048034025 0.01197114983723449
34.00000000000021 0.015161644465159503 0.012017499204942772
34.100000000000215 0.015152489355703784 0.012061636377363821
34.200000000000216 0.015143513606755933 0.012103561354497638
34.30000000000022 0.015134709200016201 0.012143274136344251
34.40000000000022 0.015126068210420897 0.012180774722903603
34.50000000000022 0.015117582804791118 0.01221606311417578
34.60000000000022 0.015109245240504946 0.01224913931016075
34.70000000000022 0.015101047864192585 0.01228000331085849
34.800000000000225 0.015092983110454022 0.01230865511626894
34.900000000000226 0.015085043500598671 0.01233509472639227
35.00000000000023 0.015077221641406725 0.01235932214122834
35.10000000000023 0.01506951022391158 0.012381337360777206
35.20000000000023 0.015061902022203068 0.012401140385038867
35.30000000000023 0.015054389892251028 0.01241873121401324
35.40000000000023 0.015046966770748802 0.012434109847700464
35.500000000000234 0.015039625673976294 0.012447276286100456
35.600000000000236 0.01503235969668216 0.012458230529213243
35.70000000000024 0.015025162010984824 0.012466972577038743
35.80000000000024 0.015018025865291891 0.012473502429577066
35.90000000000024 0.015010944583237625 0.012477820086828212
36.00000000000024 0.015003911562638122 0.012479925548792098
36.10000000000024 0.01499692014950144 0.012479571966590303
36.200000000000244 0.014989961455303628 0.012475531282629598
36.300000000000246 0.014983024660149152 0.012467635895262036
36.40000000000025 0.014976098993706872 0.01245588580448767
36.50000000000025 0.014969173803676666 0.01244028101030667
36.60000000000025 0.014962238554176993 0.012420821512718755
36.70000000000025 0.014955282824158814 0.012397507311724093
36.80000000000025 0.01494829630584536 0.01237033840732274
36.900000000000254 0.014941268803197275 0.012339314799514528
37.000000000000256 0.014934190230402667 0.012304436488299514
37.10000000000026 0.014927050610391533 0.012265703473677864
37.20000000000026 0.01491984007337421 0.0122231157556493
37.30000000000026 0.014912548855403277 0.012176673334213989
37.40000000000026 0.014905167296958554 0.012126376209371875
37.50000000000026 0.014897685841554745 0.01207222438112307
37.600000000000264 0.014890095034371303 0.012014217849467407
37.700000000000266 0.014882385520904057 0.011952356614404996
37.80000000000027 0.014874548045638317 0.011886640675935894
37.90000000000027 0.014866573450742914 0.011817070034059879
38.00000000000027 0.014858452674784917 0.011743644688777116
38.10000000000027 0.014850176751464524 0.011666364640087662
38.20000000000027 0.014841736808369919 0.01158522988799135
38.300000000000274 0.01483312406575152 0.011500240432488235
38.400000000000276 0.014824329835315491 0.011411396273578484
38.50000000000028 0.01481534551903598 0.011318697411261819
38.60000000000028 0.014806162607985849 0.011222143845538407
38.70000000000028 0.014796772681185516 0.011121735576408304
38.80000000000028 0.014787167404469637 0.011017472603871287
38.90000000000028 0.014777338529371215 0.010909354927927523
39.000000000000284 0.014767277892022918 0.010797382548577122
39.100000000000286 0.014756977412075243 0.010681555465819864
39.20000000000029 0.01474642909163123 0.010561873679655692
39.30000000000029 0.014735625014197446 0.01043833719008494
39.40000000000029 0.014724557343650954 0.01031094599710733
39.50000000000029 0.014713218323221965 0.010179700100722916
39.60000000000029 0.014701600274491886 0.010044599500931811
39.700000000000294 0.014689695596406557 0.009905644197733848
39.800000000000296 0.014677496764304321 0.009762834191129083
39.9000000000003 0.014664996328958714 0.009616169481117737
40.0000000000003 0.014652186915635548 0.009465650067699422
40.1000000000003 0.014639061223164067 0.009311275950874304
40.2000000000003 0.014625612023021971 0.009153047130642439
40.3000000000003 0.014611832158434092 0.008990963607003938
40.400000000000304 0.01459771454348442 0.008825025379958523
40.500000000000306 0.014583252162241288 0.008655232449506362
40.60000000000031 0.014568439494478164 0.008492030278460072
40.70000000000031 0.014553410299553513 0.008411217579896671
40.80000000000031 0.014538257688710941 0.008331206109742292
40.90000000000031 0.014522984526195356 0.008251995867996922
41.00000000000031 0.014507593648307792 0.008173586854660617
41.100000000000314 0.014492087863745394 0.00809597906973332
41.200000000000315 0.0144764699539364 0.008019172513215059
41.30000000000032 0.014460742673370277 0.007943167185105848
41.40000000000032 0.014444908749923057 0.007867963085405646
41.50000000000032 0.014428970885178003 0.007793560214114481
41.60000000000032 0.014412931754741615 0.00771995857123238
41.70000000000032 0.01439679400855509 0.007647158156759273
41.800000000000324 0.014380560271201352 0.007575158970695203
41.900000000000325 0.014364233142207635 0.0075039610130401835
42.00000000000033 0.014347815196343768 0.007433564283794186
42.10000000000033 0.01433130898391621 0.0073639687829572115
42.20000000000033 0.014314717031057897 0.007295174510529301
42.30000000000033 0.01429804184001399 0.007227181466510385
42.40000000000033 0.01428128588942356 0.0071599896509005195
42.500000000000334 0.014264451634597308 0.007093599063699704
42.600000000000335 0.014247541507791374 0.007028009704907898
42.70000000000034 0.014230557918477302 0.006963221574525114
42.80000000000034 0.014213503253608206 0.006899234672551394
42.90000000000034 0.01419637987788123 0.006836048998986682
43.00000000000034 0.014179190133996327 0.006773664553830994
43.10000000000034 0.014161936342911472 0.006712081337084369
43.200000000000344 0.014144620804094274 0.006651299348746767
43.300000000000345 0.01412724579577015 0.0065913185888181736
43.40000000000035 0.01410981357516705 0.00653213905729863
43.50000000000035 0.0140923263787568 0.006473760754188138
43.60000000000035 0.014074786422493147 0.006416183679486653
43.70000000000035 0.014057195902046493 0.006359407833194192
43.80000000000035 0.01403955699303547 0.006303433215310808
43.900000000000354 0.014021871851255299 0.006248259825836405
44.000000000000355 0.014004142612903057 0.006193887664771053
44.10000000000036 0.013986371394799897 0.0061403167321147645
44.20000000000036 0.013968560294610204 0.006087547027867471
44.30000000000036 0.013950711391057845 0.0060355785520292
44.40000000000036 0.013932826744139428 0.005984411304600007
44.50000000000036 0.013914908395334744 0.005934045285579809
44.600000000000364 0.013896958367814355 0.005884480494968647
44.700000000000365 0.013878978666644374 0.005835716932766549
44.80000000000037 0.01386097127898855 0.00578775459897346
44.90000000000037 0.01384293817430761 0.00574059349358938
45.00000000000037 0.013824881304555966 0.0056942336166143775
45.10000000000037 0.013806802604375794 0.005648674968048384
45.20000000000037 0.013788703991288537 0.005603917547891413
45.300000000000374 0.01377058736588389 0.005559961356143506
45.400000000000375 0.013752454612006259 0.005516806392804607
45.50000000000038 0.013734307596938784 0.0054744526578747316
45.60000000000038 0.013716148171584928 0.005432900151353934
45.70000000000038 0.013697978170647685 0.005392148873242131
45.80000000000038 0.013679799412806438 0.00535219882353935
45.90000000000038 0.013661613700891518 0.005313050002245634
46.000000000000384 0.01364342282205647 0.00527470240936094
46.100000000000385 0.013625228547948079 0.005237156044885255
46.20000000000039 0.013607032634874202 0.005200410908818634
46.30000000000039 0.013588836823969412 0.0051644670011610355
46.40000000000039 0.013570642841358492 0.005129324321912446
46.50000000000039 0.013552452398317847 0.005094982871072934
46.60000000000039 0.013534267191434813 0.005061442648642431
46.700000000000394 0.013516088902764926 0.005028703654620936
46.800000000000395 0.01349791919998718 0.00499676588900852
46.9000000000004 0.013479759736557297 0.004965629351805112
47.0000000000004 0.013461612151859035 0.004935294043010713
47.1000000000004 0.013443478071353567 0.004905759962625392
47.2000000000004 0.013425359106726978 0.004877027110649079
47.3000000000004 0.013407256856035868 0.004849095487081803
47.400000000000404 0.013389172903851125 0.004821965091923577
47.500000000000405 0.013371108821399892 0.00479563592517436
47.600000000000406 0.013353066166705712 0.004770107986834166
47.70000000000041 0.013335046484726946 0.004745381276903035
47.80000000000041 0.013317051307493433 0.004721455795380913
47.90000000000041 0.013299082154241445 0.004698331542267814
48.00000000000041 0.013281140531546942 0.004676008517563779
48.10000000000041 0.013263227933457203 0.004654486721268752
48.200000000000415 0.01324534584162076 0.004633766153382762
48.300000000000416 0.013227495725415771 0.004613846813905836
48.40000000000042 0.013209679042076766 0.004594728702837905
48.50000000000042 0.013191897236819853 0.004576411820178997
48.60000000000042 0.013174151742966357 0.00455889616592918
48.70000000000042 0.013156443982064933 0.00454218174008833
48.80000000000042 0.013138775364012216 0.004526268542656545
48.900000000000425 0.013121147287171927 0.0045111565736337955
49.000000000000426 0.013103561138492583 0.004496845833020069
49.10000000000043 0.013086018293623727 0.004483336320815351
49.20000000000043 0.013068520117030758 0.004470628037019725
49.30000000000043 0.013051067962108365 0.004458720981633094
49.40000000000043 0.01303366317129258 0.004447615154655485
49.50000000000043 0.01301630707617146 0.004437310556086926
49.600000000000435 0.012999000997594445 0.00442780718592739
49.700000000000436 0.012981746245780407 0.004419105044176891
49.80000000000044 0.012964544120424366 0.004411204130835442
49.90000000000044 0.012947395910802944 0.004404104445903001
50.00000000000044 0.012930302895878553 0.004397805989379597
50.10000000000044 0.012913266344402326 0.004392308761265243
50.20000000000044 0.012896287515015823 0.0043876127615598975
50.300000000000445 0.012879367656351531 0.004383717990263589
50.400000000000446 0.01286250800713216 0.00438062444737633
50.50000000000045 0.012845709796268734 0.00437833213289808
50.60000000000045 0.012828974242957586 0.00437684104682888
50.70000000000045 0.012812302556776142 0.004376151189168717
50.80000000000045 0.012795695869190245 0.004376098980724934
50.90000000000045 0.01277915442147224 0.004376098980724934
51.000000000000455 0.012762677842176657 0.004376098980724934
51.100000000000456 0.012746265750471272 0.004376098980724934
51.20000000000046 0.012729917768499112 0.004376098980724934
51.30000000000046 0.012713633521349453 0.004376098980724934
51.40000000000046 0.012697412637029172 0.004376098980724934
51.50000000000046 0.012681254746434407 0.004376098980724934
51.60000000000046 0.012665159483322565 0.004376098980724934
51.700000000000465 0.01264912648428466 0.004376098980724934
#include <iostream>
#include <vector>
#include <ql/math/interpolations/convexmonotoneinterpolation.hpp>
#include <ql/math/interpolations/cubicinterpolation.hpp>
using QuantLib::ConvexMonotone;
using QuantLib::Cubic;
using QuantLib::CubicInterpolation;
using QuantLib::Interpolation;
/*
interpolations >interpolations.csv
gnuplot
set datafile separator ","
set key autotitle columnhead
plot "interpolations.csv" using 1:2 with lines, \
"interpolations.csv" using 1:3 with lines, \
"interpolations.csv" using 1:4 with lines, \
"convexMonotoneClassic.csv" using 1:3 with lines title "classic"
*/
int main(int argc, char** argv) {
std::vector<std::pair<double, double>> termsAndRates = {{0.280556, -0.00318307}, //
{0.530556, -0.0026903956984000005}, //
{0.780556, -0.00214323187344}, //
{1.03889, -0.0017452071299945025}, //
{1.29167, 5.503605550280881E-4}, //
{1.54167, 0.002717478248399999}, //
{1.79444, 0.005391184238635917}, //
{2.04167, 0.007665870736439757}, //
{3.05278, 0.007744242110581442}, //
{4.06389, 0.017729991087517678}, //
{5.07778, 0.021453060571363754}, //
{6.09444, 0.02390489440875023}, //
{7.10833, 0.026754087375356297}, //
{8.12778, 0.028447902197263206}, //
{9.13889, 0.028451203745388735}, //
{10.1528, 0.029868841405055697}, //
{12.1806, 0.025411253397770967}, //
{15.225, 0.023525252364998035}, //
{20.3, 0.017342100000000006}, //
{25.375, 0.007401899999999994}, //
{30.45, 0.007900499999999987}, //
{40.5889, 0.011248767804199675}, //
{50.7361, 0.00575108261786502}};
std::vector<double> terms;
std::vector<double> rates;
for (std::pair<double, double> termAndRate : termsAndRates) {
terms.push_back(termAndRate.first);
rates.push_back(termAndRate.second);
}
Interpolation krugerCubic = Cubic(CubicInterpolation::Kruger).interpolate(terms.begin(), terms.end(), rates.begin());
Interpolation convexMonotone = ConvexMonotone(0.3, 0.7, false).interpolate(terms.begin(), terms.end(), rates.begin());
// A setting of monotonicity = 1 and quadraticity = 0 will reproduce the basic Hagan/West method.
Interpolation basicConvexMonotone =
ConvexMonotone(0, 1, false).interpolate(terms.begin(), terms.end(), rates.begin());
std::cout << "term, krugerCubic, convexMonotone, basicConvexMonotone" << '\n';
for (double term = std::max(0.0, convexMonotone.xMin()); term <= convexMonotone.xMax(); term += 0.1) {
std::cout << term << ", " //
<< krugerCubic(term) << ", " //
<< convexMonotone(term) << ", " //
<< basicConvexMonotone(term) << '\n';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment