|
From: Daniel <gr...@gm...> - 2022-08-30 15:04:45
|
Peter, Thank you for your answer. I tried Gaussian1dJamshidianSwaptionEngine(model), now I can get the calibrated model parameters. My exercise is to calibrate 1F hw model parameter using the whole vol surface, so I can use it for pricing(such as swaption). Sorry I am not familiar with option strip, can you elaborate on what is the model associated with option strip. If 1F HW model is not good to calibrate the whole vol surface, how about G2++ model? Thanks, Mark On Sat, Aug 27, 2022 at 7:27 AM Peter Caspers <pca...@gm...> wrote: > Hi Daniel > > you could use the Gaussian1dJamshidianSwaptionEngine instead of the > engine based on numerical integration. However I notice we never added > an override for zerobondOption() in the GSR model class, so we'll fall > back on the numerical integration implemented in the Gaussian1dModel > base class. To be honest, the whole implementation of the "Gaussian1d" > - framework was always more geared towards the Markov functional model > and the GSR model was more a "trivial by-product". > > As seen from today I'd rather consolidate the LGM1F model implemented in > > > https://github.com/OpenSourceRisk/Engine/blob/master/QuantExt/qle/models/lgm.hpp > > into the core library and use the engines associated with that model. > Not sure if I'd deprecate the GSR imlementation, but it duplicates > functionality alright and we don't want to maintain both models in the > long term. That might not help you immediately, especially since you > are using the QuantLib Python wrapper! I still wanted to mention it > since that consolidation would make a lot of sense in my opinion. > > More generally, could you elaborate on what the goal of your exercise > is? A Hull White 1F model is not really designed to fit a whole vol > matrix, an option strip is really all it can handle well? > > Finally, since we have Dmitri on this thread, here is a crazy idea: > Use his AADC library to tape the slow GSR-pricing of the 13x13 > swaptions and then replay the tape during the optimization to speed > that up. That might be an interesting case study for the technology? > > Thanks > Peter > > > > > > On Thu, 25 Aug 2022 at 11:10, Daniel <gr...@gm...> wrote: > > > > Thank you Peter for your information. I overwrote T to 61, now I can see > runtimeError is gone. > > > > But I had a new issue of very long calibration time now. > > I am calibrating a 13 (maturity) x 13 (tenor) volatility surface, and I > am using constant mean reversions and piecewise constant volatility as > below: > > stepDates is set at time grid @ [1,2,5,7,10,20] year from the valuation > date > > reversions = [ql.QuoteHandle(ql.SimpleQuote(0.0001))] > > sigmas = [ql.QuoteHandle(ql.SimpleQuote(0.006)) for i in range(0, > len(stepDates)+1)] > > > > In order to expedite calibration, I used low optimization criteria for > LM method and end criteria as below. But I tested below code, the code can > solve low dimension volatility surface(which means the code is working), > but it takes already 6 hours and haven't solved 13X13 volatility surfaces. > Any suggestion to calibrate faster? > > > > model = ql.Gsr(term_structure,stepDates, sigmas,reversions,61); > > engine = ql.Gaussian1dSwaptionEngine(model, 64, 7.0, True, False, > term_structure) > > swaptions = create_swaption_helpers(data, index, term_structure, engine) > > optimization_method =ql.LevenbergMarquardt(1.0e-2,1.0e-2,1.0e-2) > > end_criteria = ql.EndCriteria(1000, 10, 1e-2, 1e-3, 1e-3) > > model.calibrate(swaptions, optimization_method, end_criteria) > > > > Thanks, > > Mark > > > > On Wed, Aug 24, 2022 at 9:36 AM Peter Caspers <pca...@gm...> > wrote: > >> > >> Hi Daniel > >> > >> yes you'd change T in the ctor call ql.Gsr(...). > >> > >> 1. T is the maturity of the zero bond P(0, T) used as a numeraire in > >> the T-Forward measure > >> 2. years > >> 3. slightly higher than 60 I'd think to capture day counter / > >> convention / lag effects, maybe 61 is sufficient already > >> > >> Thanks > >> Peter > >> > >> > >> On Wed, 24 Aug 2022 at 11:47, Daniel <gr...@gm...> wrote: > >> > > >> > Peter, > >> > Thank you for your reply. > >> > Just want to make sure overwriting T means I should change below > statement > >> > model = ql.Gsr(term_structure,stepDates, > sigmas,reversions,T=60); > >> > to use some other T value instead, am I right? > >> > Two questions: > >> > 1. What is the meaning of T here? > >> > 2. What is the unit for T (month, year)? > >> > 3. If my calibrated swaption has a maximum 30Y x 30Y matrix, what is > the T value I should use? > >> > > >> > Thanks, > >> > Mark > >> > > >> > > >> > On Tue, Aug 23, 2022 at 1:30 PM Peter Caspers <pca...@gm...> > wrote: > >> >> > >> >> Hi > >> >> > >> >> the GSR model operates in the T-forward measure with T=60 by > default. You can overwrite T in the constructor if longer horizons are > needed (as it appears to be the case in your setup). > >> >> > >> >> Best > >> >> Peter > >> >> > >> >> > >> >> Daniel <gr...@gm...> schrieb am Mo. 22. Aug. 2022 um 21:25: > >> >>> > >> >>> Thank you Dmitri for your information. Actually I increased the vol > surface number to more than to be calibration volatility number, now I can > solve for mean reversion and volatility now. > >> >>> > >> >>> But experience another error when I tried to change the yield > curve and volatility surface to some other type, I got below error. > >> >>> > >> >>> ---> 14 model.calibrate(swaptions, optimization_method, > end_criteria) > >> >>> > >> >>> ~\.conda\envs\tf-gpu\lib\site-packages\QuantLib\QuantLib.py in > calibrate(self, *args) > >> >>> > >> >>> def calibrate(self, *args): > >> >>> > return _QuantLib.Gsr_calibrate(self, *args) > >> >>> > >> >>> def setParams(self, params): > >> >>> > >> >>> RuntimeError: G(t,w) should be called with (t,w)=(29.9985,60.0055) > in Range [0,60]. > >> >>> > >> >>> > >> >>> What does this runtimeError mean? > >> >>> > >> >>> > >> >>> Thanks, > >> >>> > >> >>> Mark > >> >>> > >> >>> > >> >>> > >> >>> > >> >>> > >> >>> > >> >>> On Mon, Aug 22, 2022 at 12:50 PM Dmitri Goloubentsev < > dm...@ma...> wrote: > >> >>>> > >> >>>> Hi Mark, > >> >>>> > >> >>>> > >> >>>> The error is coming from LM optimiser. You should reduce number of > points in your vol surface or add more calibration instruments or add some > sort of regularisation. > >> >>>> > >> >>>> Kind regards, > >> >>>> Dmitri. > >> >>>> > >> >>>> On Mon, 22 Aug 2022, 17:26 Daniel, <gr...@gm...> wrote: > >> >>>>> > >> >>>>> All, > >> >>>>> > >> >>>>> Please forgive me if someone has answered a similar question > before. > >> >>>>> > >> >>>>> I am trying to calibrate interest rate vol surface using GSR > (gaussian short rate model) based on this post > >> >>>>> > http://gouthamanbalaraman.com/blog/short-interest-rate-model-calibration-quantlib.html > >> >>>>> > >> >>>>> and I found a python example for GSR model calibration. > >> >>>>> > https://github.com/mlungwitz/notebooks/blob/master/GSR_Example.ipynb > >> >>>>> > >> >>>>> What I tried to do is to calibrate the same european swaption vol > surface in the 1st python example based on 2nd example gsr model > specification, what I added is: > >> >>>>> gsr = ql.Gsr(term_structure,stepDates, sigmas,reversions); > >> >>>>> engine = ql.Gaussian1dSwaptionEngine(gsr, 64, 7.0, True, False, > term_structure) > >> >>>>> swaptions = create_swaption_helpers(data, index, term_structure, > engine) > >> >>>>> > >> >>>>> optimization_method = ql.LevenbergMarquardt(1.0e-8,1.0e-8,1.0e-8) > >> >>>>> end_criteria = ql.EndCriteria(1000, 100, 1e-6, 1e-8, 1e-8) > >> >>>>> model.calibrate(swaptions, optimization_method, end_criteria) > >> >>>>> > >> >>>>> But this will give me this error: > >> >>>>> > >> >>>>> RuntimeError: less functions (5) than available variables (12) > >> >>>>> > >> >>>>> Is the error caused by Gaussian1dSwaptionEngine? Should I proceed > with Gaussian1dNonstandardSwaptionEngine? What change should I do to make > it work ? > >> >>>>> > >> >>>>> > >> >>>>> Thanks, > >> >>>>> > >> >>>>> Mark > >> >>>>> > >> >>>>> _______________________________________________ > >> >>>>> QuantLib-users mailing list > >> >>>>> Qua...@li... > >> >>>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users > >> >>> > >> >>> _______________________________________________ > >> >>> QuantLib-users mailing list > >> >>> Qua...@li... > >> >>> https://lists.sourceforge.net/lists/listinfo/quantlib-users > |