Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QuantLib C++ library - FixedRateBond coupons

Tags:

c++

quantlib

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?

like image 221
Enrico Detoma Avatar asked Oct 14 '13 13:10

Enrico Detoma


2 Answers

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.

like image 199
Luigi Ballabio Avatar answered Nov 04 '22 03:11

Luigi Ballabio


At a wild stab in the dark, the schedule sounds likely.
This takes a vector of dates. See the docs

like image 37
doctorlove Avatar answered Nov 04 '22 03:11

doctorlove