I'm using QuantLib in Python to calculate the z-spread of a bond. I have a RelinkableYieldTermStructureHandle
for the yield curve, but I'm getting a TypeError when I try to pass this handle to the ql.BondFunctions.zSpread()
function.
Wrong number or type of arguments for overloaded function 'BondFunctions_zSpread'.
Possible C/C++ prototypes are:
BondFunctions::zSpread(Bond const &,Real,ext::shared_ptr< YieldTermStructure > const &,DayCounter const &,Compounding,Frequency,Date,Real,Size,Rate)
BondFunctions::zSpread(Bond const &,Real,ext::shared_ptr< YieldTermStructure > const &,DayCounter const &,Compounding,Frequency,Date,Real,Size)
BondFunctions::zSpread(Bond const &,Real,ext::shared_ptr< YieldTermStructure > const &,DayCounter const &,Compounding,Frequency,Date,Real)
BondFunctions::zSpread(Bond const &,Real,ext::shared_ptr< YieldTermStructure > const &,DayCounter const &,Compounding,Frequency,Date)
BondFunctions::zSpread(Bond const &,Real,ext::shared_ptr< YieldTermStructure > const &,DayCounter const &,Compounding,Frequency)
Here's the relevant part of my code:
z_spread = ql.BondFunctions.zSpread(self.bond,bond_dirty_price, self.yield_curve , ql.SimpleDayCounter(), ql.SimpleThenCompounded, ql.Annual)
Where :
self.bond -> <class 'QuantLib.QuantLib.FixedRateBond'>
bond_dirty_price -> 98.943322
self.yield_curve -> <class 'QuantLib.QuantLib.RelinkableYieldTermStructureHandle'>
This gives me the above TypeError with the message "Wrong number or type of arguments for overloaded function BondFunctions_zSpread
."
I expected that the RelinkableYieldTermStructureHandle
could be used in place of a YieldTermStructureHandle
or ext::shared_ptr< YieldTermStructure >
, but it seems that this isn't the case. Can anyone explain what I'm doing wrong and how to correct this?