Skip to content

Commit

Permalink
Optional redemption argument for amortizing bond constructors (#1790)
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio authored Sep 20, 2023
2 parents 6400e4d + b742601 commit 7e0e5df
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
5 changes: 3 additions & 2 deletions ql/instruments/bonds/amortizingcmsratebond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ namespace QuantLib {
const std::vector<Rate>& caps,
const std::vector<Rate>& floors,
bool inArrears,
const Date& issueDate)
const Date& issueDate,
const std::vector<Real>& redemptions)
: Bond(settlementDays, schedule.calendar(), issueDate) {

maturityDate_ = schedule.endDate();
Expand All @@ -54,7 +55,7 @@ namespace QuantLib {
.withFloors(floors)
.inArrears(inArrears);

addRedemptionsToCashflows();
addRedemptionsToCashflows(redemptions);

QL_ENSURE(!cashflows().empty(), "bond with no cashflows!");

Expand Down
3 changes: 2 additions & 1 deletion ql/instruments/bonds/amortizingcmsratebond.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ namespace QuantLib {
const std::vector<Rate>& caps = {},
const std::vector<Rate>& floors = {},
bool inArrears = false,
const Date& issueDate = Date());
const Date& issueDate = Date(),
const std::vector<Real>& redemptions = { 100.0 });
};

}
Expand Down
10 changes: 7 additions & 3 deletions ql/instruments/bonds/amortizingfixedratebond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ namespace QuantLib {
const Period& exCouponPeriod,
const Calendar& exCouponCalendar,
const BusinessDayConvention exCouponConvention,
bool exCouponEndOfMonth)
bool exCouponEndOfMonth,
const std::vector<Real>& redemptions,
Natural paymentLag)
: Bond(settlementDays, schedule.calendar(), issueDate),
frequency_(schedule.tenor().frequency()),
dayCounter_(accrualDayCounter) {
Expand All @@ -49,9 +51,10 @@ namespace QuantLib {
.withExCouponPeriod(exCouponPeriod,
exCouponCalendar,
exCouponConvention,
exCouponEndOfMonth);
exCouponEndOfMonth)
.withPaymentLag(paymentLag);

addRedemptionsToCashflows();
addRedemptionsToCashflows(redemptions);

QL_ENSURE(!cashflows().empty(), "bond with no cashflows!");
}
Expand Down Expand Up @@ -89,6 +92,7 @@ namespace QuantLib {
addRedemptionsToCashflows();
}


AmortizingFixedRateBond::AmortizingFixedRateBond(
Natural settlementDays,
const std::vector<Real>& notionals,
Expand Down
4 changes: 3 additions & 1 deletion ql/instruments/bonds/amortizingfixedratebond.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ namespace QuantLib {
const Period& exCouponPeriod = Period(),
const Calendar& exCouponCalendar = Calendar(),
BusinessDayConvention exCouponConvention = Unadjusted,
bool exCouponEndOfMonth = false);
bool exCouponEndOfMonth = false,
const std::vector<Real>& redemptions = { 100.0 },
Natural paymentLag = 0);

/*! \deprecated Use the other constructor after calling sinkingSchedule
and sinkingNotionals to generate the required parameters.
Expand Down
7 changes: 5 additions & 2 deletions ql/instruments/bonds/amortizingfloatingratebond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ namespace QuantLib {
const Period& exCouponPeriod,
const Calendar& exCouponCalendar,
const BusinessDayConvention exCouponConvention,
bool exCouponEndOfMonth)
bool exCouponEndOfMonth,
const std::vector<Real>& redemptions,
Natural paymentLag)
: Bond(settlementDays, schedule.calendar(), issueDate) {

maturityDate_ = schedule.endDate();
Expand All @@ -52,6 +54,7 @@ namespace QuantLib {
.withPaymentDayCounter(paymentDayCounter)
.withPaymentAdjustment(paymentConvention)
.withFixingDays(fixingDays)
.withPaymentLag(paymentLag)
.withGearings(gearings)
.withSpreads(spreads)
.withCaps(caps)
Expand All @@ -62,7 +65,7 @@ namespace QuantLib {
exCouponEndOfMonth)
.inArrears(inArrears);

addRedemptionsToCashflows();
addRedemptionsToCashflows(redemptions);

QL_ENSURE(!cashflows().empty(), "bond with no cashflows!");

Expand Down
6 changes: 4 additions & 2 deletions ql/instruments/bonds/amortizingfloatingratebond.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ namespace QuantLib {
const Period& exCouponPeriod = Period(),
const Calendar& exCouponCalendar = Calendar(),
BusinessDayConvention exCouponConvention = Unadjusted,
bool exCouponEndOfMonth = false);
bool exCouponEndOfMonth = false,
const std::vector<Real>& redemptions = { 100.0 },
Natural paymentLag = 0);
};

}

#endif

0 comments on commit 7e0e5df

Please sign in to comment.