|
From: Ben W. <ben...@ma...> - 2022-12-07 10:06:34
|
Ahh - thank you Luigi.... On Wed, 7 Dec 2022, 7:36 pm Luigi Ballabio, <lui...@gm...> wrote: > Hello Ben, > short answer - tm should be a handle too, as in: > > tm = ql.QuoteHandle(ql.SimpleQuote(spread/10000)) > > Luigi > > > On Wed, Dec 7, 2022 at 8:37 AM Ben Watson <ben...@ma...> > wrote: > >> I am pricing some FRN’s and struggling to get code block below work. >> >> >> >> The error on the line zsts=ql.ZeroSpreadedTermStructure(self.fc,tm) and >> what I get back is; >> >> >> >> Exception is: Wrong number or type of arguments for overloaded function >> 'new_ZeroSpreadedTermStructure'. >> >> Possible C/C++ prototypes are: >> >> ZeroSpreadedTermStructure::ZeroSpreadedTermStructure(Handle< >> YieldTermStructure > const &,Handle< Quote > const >> &,Compounding,Frequency,DayCounter const &) >> >> ZeroSpreadedTermStructure::ZeroSpreadedTermStructure(Handle< >> YieldTermStructure > const &,Handle< Quote > const >> &,Compounding,Frequency) >> ZeroSpreadedTermStructure::ZeroSpreadedTermStructure(Handle< >> YieldTermStructure > const &,Handle< Quote > const &,Compounding) >> >> ZeroSpreadedTermStructure::ZeroSpreadedTermStructure(Handle< >> YieldTermStructure > const &,Handle< Quote > const &) >> >> >> >> However self.fc is type <class >> 'QuantLib.QuantLib.RelinkableYieldTermStructureHandle'> >> >> and tm is <class 'QuantLib.QuantLib.SimpleQuote'> >> >> >> >> I have tried with a regular non-linkable <class >> 'QuantLib.QuantLib.YieldTermStructureHandle'> and still get the same >> error. >> >> >> >> Any ideas on what is going on??? By the looks of it the error message >> maybe >> misleading. >> >> >> >> >> >> def calc_dm(self,price): >> >> >> >> @timeit >> >> def FairDM(spread): >> >> tm = ql.SimpleQuote(spread/10000) >> >> print(type(self.fc),type(tm)) >> >> zsts=ql.ZeroSpreadedTermStructure(self.fc,tm) >> >> self.dc.linkTo(zsts) >> >> cp=self.frn.cleanPrice() >> >> return price-cp >> >> >> >> accuracy = 1e-1 >> >> guess =300 >> >> step = 0.1 >> >> >> >> self.frn.setPricingEngine(ql.DiscountingBondEngine(self.dc)) >> >> self.fc.linkTo(self.projection_curve) >> >> >> >> FairSpread=ql.Brent().solve(FairDM, accuracy, guess, step) >> >> self.dm_spread= FairSpread >> >> >> >> _______________________________________________ >> QuantLib-users mailing list >> Qua...@li... >> https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > |