|
From: Ben W. <ben...@ma...> - 2022-12-07 07:34:36
|
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
|