Skip to content

Commit

Permalink
added redemptions to amortizing bond constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
gyansinha committed Sep 18, 2023
1 parent cd33939 commit f8da734
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 16 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
5 changes: 3 additions & 2 deletions ql/instruments/bonds/amortizingcmsratebond.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ 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 });
};

}

#endif
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
8 changes: 6 additions & 2 deletions ql/instruments/bonds/amortizingfixedratebond.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace QuantLib {
//! amortizing fixed-rate bond
class AmortizingFixedRateBond : public Bond {
public:
AmortizingFixedRateBond(Natural settlementDays,
AmortizingFixedRateBond(Natural settlementDays,
const std::vector<Real>& notionals,
const Schedule& schedule,
const std::vector<Rate>& coupons,
Expand All @@ -44,7 +44,10 @@ 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 Expand Up @@ -79,6 +82,7 @@ namespace QuantLib {
BusinessDayConvention exCouponConvention = Unadjusted,
bool exCouponEndOfMonth = false);


Frequency frequency() const { return frequency_; }
const DayCounter& dayCounter() const { return dayCounter_; }
protected:
Expand Down
11 changes: 7 additions & 4 deletions ql/instruments/bonds/amortizingfloatingratebond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@

namespace QuantLib {

AmortizingFloatingRateBond::AmortizingFloatingRateBond(

AmortizingFloatingRateBond::AmortizingFloatingRateBond(
Natural settlementDays,
const std::vector<Real>& notionals,
const Schedule& schedule,
const ext::shared_ptr<IborIndex>& index,
const DayCounter& paymentDayCounter,
BusinessDayConvention paymentConvention,
Natural fixingDays,
Natural fixingDays, Natural paymentLag,
const std::vector<Real>& gearings,
const std::vector<Spread>& spreads,
const std::vector<Rate>& caps,
Expand All @@ -42,7 +43,8 @@ namespace QuantLib {
const Period& exCouponPeriod,
const Calendar& exCouponCalendar,
const BusinessDayConvention exCouponConvention,
bool exCouponEndOfMonth)
bool exCouponEndOfMonth,
const std::vector<Real>& redemptions)
: 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
9 changes: 6 additions & 3 deletions ql/instruments/bonds/amortizingfloatingratebond.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ namespace QuantLib {
//! amortizing floating-rate bond (possibly capped and/or floored)
class AmortizingFloatingRateBond : public Bond {
public:

AmortizingFloatingRateBond(Natural settlementDays,
const std::vector<Real>& notional,
const Schedule& schedule,
const ext::shared_ptr<IborIndex>& index,
const DayCounter& accrualDayCounter,
BusinessDayConvention paymentConvention = Following,
Natural fixingDays = Null<Natural>(),
Natural paymentLag = Null<Natural>(),
const std::vector<Real>& gearings = { 1.0 },
const std::vector<Spread>& spreads = { 0.0 },
const std::vector<Rate>& caps = {},
Expand All @@ -50,9 +52,10 @@ 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 });
};

}

#endif

0 comments on commit f8da734

Please sign in to comment.