|
From: Luigi B. <lui...@gm...> - 2020-09-23 11:23:35
|
ZeroCurve is shorthand for InterpolatedZeroCurve<Linear>. You can also use InterpolatedZeroCurve<LogLinear> etc. Luigi On Sat, Sep 19, 2020 at 7:05 PM Daniel Lobo <dan...@gm...> wrote: > Okay. > > Is there any way to set the extrapolation method like linear, non-linear > etc? > > On Sat, 19 Sep 2020 at 22:29, Amine Ifri <ami...@gm...> wrote: > > > > I dont see anything wrong with your call. I suspect this has to do with > the Black pricing formula used for valuing the swaption. That is where you > would have to look for the mistake. > > > > > On 19 Sep 2020, at 17:54, Daniel Lobo <dan...@gm...> wrote: > > > > > > Thanks. > > > > > > I tried to enable extrapolation with below snippet - > > > > > > std::vector<QuantLib::Date> sr_dt; > > > std::vector<QuantLib::Real> sr_v; > > > sr_dt.push_back(Date(15, February, 2002)); > > > sr_dt.push_back(Date(15, February, 2003)); > > > sr_dt.push_back(Date(15, February, 2004)); > > > sr_v.push_back(0); > > > sr_v.push_back(3.5/100); > > > sr_v.push_back(6/100); > > > > > > Handle<YieldTermStructure> > > > rhTermStructure(ext::make_shared<ZeroCurve>(sr_dt, sr_v, > > > Actual365Fixed())); > > > rhTermStructure->enableExtrapolation(); > > > > > > However with this I am getting below error - > > > > > > strike + displacement (-0.0621661 + 0) must be non-negative > > > > > > Is there any better way to enable extrapolation? > > > > > > Thanks again for your help. > > > > > > On Sat, 19 Sep 2020 at 21:36, Amine Ifri <ami...@gm...> wrote: > > >> > > >> Hi Daniel, > > >> > > >> The curve and the instrument you are pricing are independent: curve > is only based on the instruments you use to build it and their tenor > points, not on the cash flows of the instrument you are pricing with it. > > >> > > >> If you don’t have spot quotes that go that far, I believe you can > enable extrapolation. > > >> > > >> Hope it helps. > > >> > > >> Amine Ifri > > >> > > >>> On 19 Sep 2020, at 12:05, Daniel Lobo <dan...@gm...> > wrote: > > >>> > > >>> Hi, > > >>> > > >>> Thanks for your suggestion. I changed to below and it worked. > > >>> > > >>> std::vector<QuantLib::Date> sr_dt; > > >>> std::vector<QuantLib::Real> sr_v; > > >>> sr_dt.push_back(Date(15, February, 2002)); > > >>> sr_dt.push_back(Date(15, February, 2003)); > > >>> sr_dt.push_back(Date(15, February, 2054)); > > >>> sr_v.push_back(0); > > >>> sr_v.push_back(1.5/100); > > >>> sr_v.push_back(2/100); > > >>> > > >>> Handle<YieldTermStructure> rhTermStructure( > > >>> ext::make_shared<ZeroCurve>(sr_dt, > > >>> sr_v, > > >>> Actual365Fixed() > > >>> )); > > >>> > > >>> But my question is, shouldnt the curve automatically extrapolated > > >>> automatically to the last cash-flow date? > > >>> > > >>> What I should do if I dont have spot-quoted till that far? > > >>> > > >>>> On Sat, 19 Sep 2020 at 16:28, Amine Ifri <ami...@gm...> > wrote: > > >>>> > > >>>> Hi Daniel, > > >>>> > > >>>> I believe the error is due to an initial check on the term > structure that fails because The last tenor on the curve is less than the > maturity date of your instrument/ underlying swap. > > >>>> > > >>>> I would try setting the last tenor on the curve to be longer than > the last point on your instrument. > > >>>> > > >>>> Let me know how it goes ! > > >>>> > > >>>> Amine Ifri > > >>>> > > >>>>>> On 19 Sep 2020, at 11:27, Daniel Lobo <dan...@gm...> > wrote: > > >>>>> > > >>>>> Hi, > > >>>>> > > >>>>> I was replicating the examples as given in > > >>>>> > https://github.com/lballabio/QuantLib/blob/master/Examples/BermudanSwaption/BermudanSwaption.cpp > . > > >>>>> > > >>>>> However I changed the Term structure curve as below - > > >>>>> > > >>>>> Asin the file - > > >>>>> > > >>>>> Handle<YieldTermStructure> rhTermStructure( > > >>>>> ext::make_shared<FlatForward>( > > >>>>> settlementDate, Handle<Quote>(flatRate), > > >>>>> Actual365Fixed())); > > >>>>> > > >>>>> But I changed to - > > >>>>> > > >>>>> Handle<YieldTermStructure> rhTermStructure1( > > >>>>> ext::make_shared<FlatForward>( > > >>>>> settlementDate, Handle<Quote>(flatRate), > > >>>>> Actual365Fixed())); > > >>>>> > > >>>>> std::vector<QuantLib::Date> sr_dt; > > >>>>> std::vector<QuantLib::Real> sr_v; > > >>>>> sr_dt.push_back(Date(15, February, 2002)); > > >>>>> sr_dt.push_back(Date(15, February, 2003)); > > >>>>> sr_dt.push_back(Date(15, February, 2004)); > > >>>>> sr_v.push_back(0); > > >>>>> sr_v.push_back(1.5/100); > > >>>>> sr_v.push_back(2/100); > > >>>>> > > >>>>> Handle<YieldTermStructure> rhTermStructure( > > >>>>> ext::make_shared<ZeroCurve>(sr_dt, > > >>>>> sr_v, > > >>>>> Actual365Fixed() > > >>>>> )); > > >>>>> > > >>>>> With this change I failed to generate any value. I received error - > > >>>>> > > >>>>> 1st leg: time (2.01096) is past max curve time (2) > > >>>>> > > >>>>> Any insight why I get this error and how to resolve this would be > > >>>>> really helpful. > > >>>>> > > >>>>> Thanks for your time > > >>>>> > > >>>>> > > >>>>> _______________________________________________ > > >>>>> 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 > |