Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
qiubill opened this issue Apr 11, 2024 · 3 comments

Comments

@qiubill
Copy link

qiubill commented Apr 11, 2024

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

@lballabio
Copy link
Owner

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.

@qiubill
Copy link
Author

qiubill commented Apr 30, 2024

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?

@lballabio
Copy link
Owner

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
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants