|
From: Jonathan G. <Jon...@ni...> - 2023-09-11 06:39:36
|
Hi Marcin, Thank you for your input. Apologies for the delay in response. Before your mail I settled on the following solution: 1. If I am correct in assuming, the constant zero rate post final bond maturity will be ‘fixed’ indefinitely if the preceding forward rate is equal to the zero rate. 2. I used the ultimate forward term structure and set the ultimate forward rate equal to the sampled final zero rate at t+1 post final bond maturity - https://rkapl123.github.io/QLAnnotatedSource/dc/dbf/class_quant_lib_1_1_ultimate_forward_term_structure.html It seems to provide me with the curve I was intending. Any thoughts around this? A question for you on your linear/non-linear point, have you had any attempt/success at using Piecewise Monotone Convex interpolation using python? Thanks for your help! Jonathan George Quantitative Developer T:+27 21 901 1363 36 Hans Strijdom Avenue Foreshore, Cape Town, Western Cape, 8001, South Africa www.ninetyone.com | Follow us From: Marcin Rybacki <mry...@gm...> Sent: 07 September 2023 17:56 To: Jonathan George <Jon...@ni...> Cc: qua...@li... Subject: Re: [Quantlib-users] Bootstrapped Yield Curve extrapolation help Hi Jonathan, I think that, at the moment, the library only offers flat forward extrapolation. However, you could use the following workaround: 1) Build the curve, based on the original input rates, using linear log-discount interpolation without enabling the extrapolation 2) Retrieve the nodes of the curve, which I assume will be (in Python) a list of tuples with dates and discount factors 2) From this curve calculate a zero rate for the last node: last_zero_rate = crv.zeroRate(crv.maxTime(), ql.Continuous).rate() 3) Calculate a discount factor for the very last QuantLib date: max_dt = ql.Date.maxDate() By taking the exponent of the year fraction from the reference date to max date, times last zero rate and times -1. And append the nodes with this last tuple (date and discount factor) 4) Reconstruct the curve using ql.DiscountCurve(dates, discounts, day_counter) and enable extrapolation. I think this should give the outcome you're looking for. Please note that the above approach will only work for linear schemes. Applying it with e.g. cubic splines will lead to a different solution of the tridiagonal system, and the resulting curves will be slightly different. Another downside is that bumping quote handles to obtain sensitivities will yield incorrect outcomes in the extrapolation region - so instead you would have to rebuild the curve to get the deltas. Hope this helps. Kind regards, Marcin On Thu, 24 Aug 2023 at 15:32, Jonathan George <Jon...@ni...<mailto:Jon...@ni...>> wrote: Hi All, I am hoping that I might be able to get some help from this forum. Context: I am trying to bootstrap a yield curve using piecewise flat forward interpolation between market obtained rates. Here is my output: [cid:image003.png@01D9D69D.7A43BF10] I am using python and my curve construction is quite straight forward with extrapolation enabled(I understand I am committing the cardinal sin by not posting my code, but hoping that this is theoretical enough a question for a straight forward answer) Question: Is it possible to fix the final zero rate post maturity of the last bond? It seems that enableExtrapolation is fixing the final forward rate making the zero rate decay over time. I am trying to avoid creating a custom function to return zero and forward rates post maturity of the final bond. I have tried create two curves (a linear flat forward curve and a regular flat forward curve) and combining using CompositeZeroYieldStructure however I’m not sure which binary function to pass into the function. Any help would be appreciated. Regards Jonathan George Quantitative Developer T: +27 21 901 1363<tel:+27%2021%20901%201363> 36 Hans Strijdom Avenue Foreshore, Cape Town, 8001 www.ninetyone.com |<http://ninetyone.com/> [cid:image533918.png@E2B7D91B.840C5271]<https://www.linkedin.com/company/ninetyone/> Follow us<https://www.linkedin.com/company/ninetyone> [cid:image087679.png@D95C995A.624A21B7]<https://ninetyone.com/> _______________________________________________ QuantLib-users mailing list Qua...@li...<mailto:Qua...@li...> https://lists.sourceforge.net/lists/listinfo/quantlib-users<https://lists.sourceforge.net/lists/listinfo/quantlib-users> |