QuantLib
QuantLib copied to clipboard
what is the replacement for the removed constructors of FixedRateBond taking an InterestRate?
Hi,
I noticed that as of version 1.33, the constructor that takes InterestRate parameter for the ql.FixedRateBond has been removed, so for the old code such as below, what should be the equivalent replacement?
self.bond = ql.FixedRateBond(int(self.settlement_days),
self.face_value,
self.schedule,
[ql.InterestRate(self.coupon,
self.day_count,
self.compounding_scheme,
self.compounding_frequency)],
self.business_day_convention)
Looking forward to your reply, much appreciated!!!
Starting from release 1.34 (out later this month) it will be:
coupons = ql.FixedRateLeg(
self.schedule,
self.day_count,
[self.face_value],
interestRates=[ql.InterestRate(self.coupon,
self.day_count,
self.compounding_scheme,
self.compounding_frequency)],
paymentAdjustment=self.business_day_convention,
)
self.bond = ql.Bond(
int(self.settlement_days),
self.schedule.calendar(),
self.schedule.startDate(),
coupons,
)
No replacement in 1.33, unfortunately.
Thanks @lballabio for your answer,
What about the old code that has a redemption_value such as:
self.bond = ql.FixedRateBond(int(self.settlement_days), self.face_value, self.schedule, [ql.InterestRate(self.coupon, self.day_count, self.compounding_scheme, self.compounding_frequency)], self.business_day_convention, self.redemption_value )
How to set up that redemption_value to the bond class in the new code?
That would be
coupons = ql.FixedRateLeg(
self.schedule,
self.day_count,
[self.face_value],
interestRates=[ql.InterestRate(self.coupon,
self.day_count,
self.compounding_scheme,
self.compounding_frequency)],
paymentAdjustment=self.business_day_convention,
)
cashflows = coupons + (
ql.Redemption(self.redemption_value, self.schedule.endDate()),
)
self.bond = ql.Bond(
self.settlement_days,
self.schedule.calendar(),
self.face_value,
self.schedule.endDate(),
self.schedule.startDate(),
cashflows
)
This issue was automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment, or this will be closed in two weeks.