|
From: Peter C. <pca...@gm...> - 2024-02-06 19:06:10
|
If you are willing to use the ORE libraries (extension to QuantLib), there is a nF-Hull-White Model. It is work in progress, calibration to options and time-dependent parameters are still missing. It's particularly suitable to reproduce movements taken from a PCA on historical curve data. Here are links to some demos: https://github.com/OpenSourceRisk/Engine/tree/master/Examples/Example_37 https://github.com/OpenSourceRisk/Engine/tree/master/Examples/Example_38 Best Peter On Tue, 6 Feb 2024 at 17:01, Luigi Ballabio <lui...@gm...> wrote: > No, I'm afraid G2 is the only two-factor model we have in that framework. > There's also an implementation of LMM from the late Mark Joshi, but I'm not > familiar with it. > > Luigi > > > On Tue, Feb 6, 2024 at 1:29 PM Philippe Hatstadt < > phi...@ex...> wrote: > >> Thanks Luigi. Wow 18 years… >> Are there other models that can de-correlate CMS2Y versus CMS10Y and >> longer? Working in OAS model where slope of the curve is a principal >> component. >> Regards >> >> Philippe Hatstadt >> +1-203-252-0408 >> >> >> On Feb 6, 2024, at 7:00 AM, Luigi Ballabio <lui...@gm...> >> wrote: >> >> >> Hmm—you're right, it looks like the G2 processes are only half-done. >> From the git logs of the C++ library, it looks like they were added 18 >> years ago and never updated (and probably never used either). They should >> be fixed there. I've opened >> https://github.com/lballabio/QuantLib/issues/1904 but I don't know when >> someone will pick it up. >> >> Luigi >> >> >> On Mon, Feb 5, 2024 at 8:44 PM Philippe Hatstadt < >> phi...@ex...> wrote: >> >>> @Luigi Ballabio <lui...@gm...> trying to follow up on this >>> discussion. Here is what I found at the Python level. >>> >>> A. Apparently, there is a well-defined way of generating short rate >>> paths for HW1F as follows, per cookbook, and post calibration of a and >>> sigma: >>> >>> hw_process = HullWhiteProcess(spot_curve_handle, a, sigma) >>> rng = GaussianRandomSequenceGenerator( >>> UniformRandomSequenceGenerator(timestep, UniformRandomGenerator())) >>> seq = GaussianPathGenerator(hw_process, length, timestep, rng, False) >>> >>> B. For G2 model, I was able to find this: g2pp_fprocess = >>> G2ForwardProcess(a, sigma, b, eta, rho) or g2pp_process = G2Process(a, >>> sigma, b, eta, rho). What is puzzling is that neither call takes >>> spot_curve_handle as a parameter, which is confirmed by the SWIG >>> extract below. Does it mean that either of G2Process() / G2ForwardProcess() >>> classes are not "finished" products, and/or am I supposed to pass the term >>> structure handle in a different way? More generally, how am I supposed to >>> use this class, if at all? >>> >>> # Register G2Process in _QuantLib: >>> _QuantLib.G2Process_swigregister(G2Process) >>> class G2ForwardProcess(StochasticProcess): >>> r"""Proxy of C++ G2ForwardProcess class.""" >>> >>> thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") >>> __repr__ = _swig_repr >>> >>> >>> def __init__(self, a, sigma, b, eta, rho): >>> r"""__init__(G2ForwardProcess self, Real a, Real sigma, Real b, Real eta, Real rho) -> G2ForwardProcess""" >>> _QuantLib.G2ForwardProcess_swiginit(self, _QuantLib.new_G2ForwardProcess(a, sigma, b, eta, rho)) >>> >>> >>> Philippe Hatstadt >>> >>> >>> On Tue, Jan 30, 2024 at 11:29 AM philippe hatstadt <pha...@ma...> >>> wrote: >>> >>>> Yeah that’s what I was thinking. At least I’d be making indirect C++ >>>> calls. I might try. >>>> Regards >>>> >>>> Philippe Hatstadt >>>> +1-203-252-0408 >>>> >>>> >>>> On Jan 30, 2024, at 11:15 AM, Luigi Ballabio <lui...@gm...> >>>> wrote: >>>> >>>> >>>> Hmm, I'm not sure. The only thing that comes to mind is that, given a >>>> path for interest rates, one could create some sort of interest-rate term >>>> structure and then extract CMT rates from it. It's not something I tried, >>>> though. >>>> >>>> Luigi >>>> >>>> On Tue, Jan 30, 2024 at 1:39 PM Philippe Hatstadt < >>>> phi...@ex...> wrote: >>>> >>>>> Except I need to generate CMT rates along each path for my prepayment >>>>> model. That would have be to be a pure Python Ioop? How would you then >>>>> advise to calculate CMT rates from a path of short rates with the goal to >>>>> try and use as many wrapped Python calls to underlying C++? >>>>> >>>>> Regards >>>>> >>>>> Philippe Hatstadt >>>>> +1-203-252-0408 >>>>> >>>>> >>>>> On Jan 30, 2024, at 7:33 AM, Luigi Ballabio <lui...@gm...> >>>>> wrote: >>>>> >>>>> >>>>> It might not be so bad. The generation of the paths is driven from >>>>> Python but performed by the GaussianPathGenerator class in C++. I'd >>>>> give it a try. >>>>> >>>>> Luigi >>>>> >>>>> >>>>> On Tue, Jan 30, 2024 at 1:28 PM Philippe Hatstadt < >>>>> phi...@ex...> wrote: >>>>> >>>>>> Thank you. I looked at it and it’s great. His post-calibration >>>>>> simulation on HW is done in Python though so performance will be an issue. >>>>>> Thence my asking if there were routines existing in C++. >>>>>> >>>>>> Thank you. >>>>>> >>>>>> Regards >>>>>> >>>>>> Philippe Hatstadt >>>>>> +1-203-252-0408 >>>>>> >>>>>> >>>>>> On Jan 30, 2024, at 7:24 AM, Luigi Ballabio <lui...@gm...> >>>>>> wrote: >>>>>> >>>>>> >>>>>> Hi, not much is already existing, I'm afraid. You can have a look at >>>>>> Goutham's post at >>>>>> https://gouthamanbalaraman.com/blog/hull-white-simulation-quantlib-python.html >>>>>> (also in the cookbook if you have it) for a few ideas; he generates >>>>>> interest-rate paths based on a Hull/White model, but something similar >>>>>> should work for G2 as well. >>>>>> >>>>>> Hope this helps, >>>>>> Luigi >>>>>> >>>>>> >>>>>> On Wed, Jan 24, 2024 at 8:03 PM Philippe Hatstadt < >>>>>> phi...@ex...> wrote: >>>>>> >>>>>>> I was able to calibrate a G2++ model to normal UST swaption >>>>>>> volatilities (heroically using SOFR swaptions and re-scaling by rates ratio >>>>>>> to generate so-called Treasury Swaption vol surface). >>>>>>> Code is below: >>>>>>> >>>>>>> model = G2(term_structure); >>>>>>> # engine = TreeSwaptionEngine(model, 25) >>>>>>> # engine = ql.G2SwaptionEngine(model, 10, 400) >>>>>>> engine = ql.FdG2SwaptionEngine(model) >>>>>>> swaptions = create_swaption_helpers_normal(data, index, >>>>>>> term_structure, engine) >>>>>>> optimization_method = LevenbergMarquardt(1.0e-8,1.0e-8,1.0e-8) >>>>>>> end_criteria = EndCriteria(1000, 100, 1e-6, 1e-8, 1e-8) >>>>>>> model.calibrate(swaptions, optimization_method, end_criteria) >>>>>>> a, sigma, b, eta, rho = model.params()\ >>>>>>> >>>>>>> The question now is as follows: I want to use this model towards a >>>>>>> GNMA OAS model for which I would need monte-carlo paths of 2y/5y/10y >>>>>>> forward CMT rates spaced say monthly. >>>>>>> >>>>>>> I assume that I would first need to use the 5 G2++ parameters >>>>>>> calibrated above and then generate paths of the short rate, then somehow >>>>>>> compute forward CMT at each forward monthly epoch Ti by computing the >>>>>>> break-even coupon C10(Ti) such that PV(Ti, bond(cpn=C10(Ti)) == 100? >>>>>>> Are there existing QL classes or modules that do all that from a >>>>>>> given calibrated model like above? >>>>>>> By the same token, I would also need stochastic pathwise discount >>>>>>> factor vectors DF(Ti, path j), i=0 to 30y monthly. Is there also a QL >>>>>>> module that generates those? I can obviously do it manually, but I am on >>>>>>> the python side, so I want to re-use as much of existing libraries as I can >>>>>>> to use efficient C++ code indirectly via SWIG. >>>>>>> >>>>>>> Regards >>>>>>> >>>>>>> Philippe Hatstadt >>>>>>> >>>>>>> 1370 Broadway, Suite 1450 | New York, NY | 10018 >>>>>>> >>>>>>> [image: https://www.exosfinancial.com/] >>>>>>> <https://www.exosfinancial.com/> [image: >>>>>>> https://www.linkedin.com/company/meetexos/about/] >>>>>>> <https://www.linkedin.com/company/meetexos/about/> >>>>>>> >>>>>>> Broker-Dealer services offered through Exos Securities LLC, Member >>>>>>> SIPC, FINRA. For important disclosures including Form CRS and Regulation BI >>>>>>> click here <https://www.exosfinancial.com/general-disclosures>. >>>>>>> >>>>>>> >>>>>>> Confidentiality Notice: The information contained in this email >>>>>>> (including attachments) is only for the personal and confidential use of >>>>>>> the sender and recipient named above. If the reader is not the intended >>>>>>> recipient, you are notified that you have received this message in error >>>>>>> and that any review, dissemination, copying or distribution is prohibited. >>>>>>> If you have received this communication in error, please notify the sender >>>>>>> immediately by e-mail and delete or destroy the original message and all >>>>>>> copies. >>>>>>> _______________________________________________ >>>>>>> QuantLib-users mailing list >>>>>>> Qua...@li... >>>>>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users >>>>>>> >>>>>> >>>>>> 1370 Broadway, Suite 1450 | New York, NY | 10018 >>>>>> >>>>>> [image: https://www.exosfinancial.com/] >>>>>> <https://www.exosfinancial.com/> [image: >>>>>> https://www.linkedin.com/company/meetexos/about/] >>>>>> <https://www.linkedin.com/company/meetexos/about/> >>>>>> >>>>>> Broker-Dealer services offered through Exos Securities LLC, Member >>>>>> SIPC, FINRA. For important disclosures including Form CRS and Regulation BI >>>>>> click here <https://www.exosfinancial.com/general-disclosures>. >>>>>> >>>>>> >>>>>> Confidentiality Notice: The information contained in this email >>>>>> (including attachments) is only for the personal and confidential use of >>>>>> the sender and recipient named above. If the reader is not the intended >>>>>> recipient, you are notified that you have received this message in error >>>>>> and that any review, dissemination, copying or distribution is prohibited. >>>>>> If you have received this communication in error, please notify the sender >>>>>> immediately by e-mail and delete or destroy the original message and all >>>>>> copies. >>>>>> >>>>> >>>>> 1370 Broadway, Suite 1450 | New York, NY | 10018 >>>>> >>>>> [image: https://www.exosfinancial.com/] >>>>> <https://www.exosfinancial.com/> [image: >>>>> https://www.linkedin.com/company/meetexos/about/] >>>>> <https://www.linkedin.com/company/meetexos/about/> >>>>> >>>>> Broker-Dealer services offered through Exos Securities LLC, Member >>>>> SIPC, FINRA. For important disclosures including Form CRS and Regulation BI >>>>> click here <https://www.exosfinancial.com/general-disclosures>. >>>>> >>>>> >>>>> Confidentiality Notice: The information contained in this email >>>>> (including attachments) is only for the personal and confidential use of >>>>> the sender and recipient named above. If the reader is not the intended >>>>> recipient, you are notified that you have received this message in error >>>>> and that any review, dissemination, copying or distribution is prohibited. >>>>> If you have received this communication in error, please notify the sender >>>>> immediately by e-mail and delete or destroy the original message and all >>>>> copies. >>>>> >>>> >>> 31 East 32nd Street, 3rd Floor | New York, NY | 10016 >>> >>> [image: https://www.exosfinancial.com/] <https://www.exosfinancial.com/> [image: >>> https://www.linkedin.com/company/meetexos/about/] >>> <https://www.linkedin.com/company/meetexos/about/> >>> >>> Broker-Dealer services offered through Exos Securities LLC, Member SIPC, >>> FINRA. For important disclosures including Form CRS and Regulation BI click >>> here <https://www.exosfinancial.com/general-disclosures>. >>> >>> >>> Confidentiality Notice: The information contained in this email >>> (including attachments) is only for the personal and confidential use of >>> the sender and recipient named above. If the reader is not the intended >>> recipient, you are notified that you have received this message in error >>> and that any review, dissemination, copying or distribution is prohibited. >>> If you have received this communication in error, please notify the sender >>> immediately by e-mail and delete or destroy the original message and all >>> copies. >>> >> >> 31 East 32nd Street, 3rd Floor | New York, NY | 10016 >> >> [image: https://www.exosfinancial.com/] <https://www.exosfinancial.com/> [image: >> https://www.linkedin.com/company/meetexos/about/] >> <https://www.linkedin.com/company/meetexos/about/> >> >> Broker-Dealer services offered through Exos Securities LLC, Member SIPC, >> FINRA. For important disclosures including Form CRS and Regulation BI click >> here <https://www.exosfinancial.com/general-disclosures>. >> >> >> Confidentiality Notice: The information contained in this email >> (including attachments) is only for the personal and confidential use of >> the sender and recipient named above. If the reader is not the intended >> recipient, you are notified that you have received this message in error >> and that any review, dissemination, copying or distribution is prohibited. >> If you have received this communication in error, please notify the sender >> immediately by e-mail and delete or destroy the original message and all >> copies. >> > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |