QuantLib icon indicating copy to clipboard operation
QuantLib copied to clipboard

what is the replacement for the removed constructors of FixedRateBond taking an InterestRate?

Open qiubill opened this issue 10 months ago • 3 comments

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!!!

qiubill avatar Apr 11 '24 03:04 qiubill

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.

lballabio avatar Apr 11 '24 11:04 lballabio

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?

qiubill avatar Apr 30 '24 20:04 qiubill

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
)

lballabio avatar May 03 '24 08:05 lballabio

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.

github-actions[bot] avatar Jul 03 '24 01:07 github-actions[bot]