With the QuantLib C++ library, I'm trying to evaluate bonds which have different coupons during their lifetime (for example 6% for the first three years, then 4% for the remaining three years).
I noticed that the constructor of the FixedRateBond
class accepts a vector of coupons: const std::vector< Rate > &coupons
:
FixedRateBond (Natural settlementDays,
Real faceAmount,
const Schedule &schedule,
const std::vector< Rate > &coupons,
const DayCounter &accrualDayCounter,
BusinessDayConvention paymentConvention=Following,
Real redemption=100.0,
const Date &issueDate=Date(),
const Calendar &paymentCalendar=Calendar())
That seems to be useful for my purpose, but how can I specify at which dates each coupon starts to apply?
Just count the coupons. If your bond pays annual coupons, you'll have three coupon in the first three years and three afterwards. In that case, pass (0.06, 0.06, 0.06, 0.04, 0.04, 0.04) as the vector of coupon rates. If the coupons are semiannual, there are six of them in three years; in that case, pass a vector containing 0.06 six times and 0.04 another six times. You get the idea: pass the rate for each coupon.
At a wild stab in the dark, the schedule
sounds likely.
This takes a vector of dates. See the docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With