For some bonds I work with the last coupon date is not equal to bond's maturity date. E.g. the last coupon date is April 25th, 2020 and maturity date is April 25th, 2021. I looked at Schedule class and MakeSchedule() and I don't see a clear way to reflect this. I feel it can't be that hard, though. Would appreciate if someone gives me a hint. Thank you!
You can obtain the desired effect by tweaking the bond construction.
For instance, let's say you're creating a 4-years bond with semiannual coupons paying 3%, but missing the last. This makes for 7 coupons. Instead, you'll create the schedule as usual (so you have 8 periods), but specify a null last coupon when creating the bond. So:
Schedule schedule = ...; // as for a "normal" bond; std::vector<Rate> coupons(8, 0.03); // 8 coupons... coupons.back() = 0.0; // but the last one pays 0%. FixedRateBond bond(settlementDays, faceAmount, schedule, coupon, accrualDayCounter);
This will give you the correct price; the disadvantage is that you'll have a coupon paying 0%, which is less clean than having just the ones that actually exist. If this turns out to be a problem, you can inherit from
FixedRateCouponBond and delete the coupon in the constructor. But I would guess it's way easier to just filter out null cash flows in your client code.
You can use the same trick for most kinds of bond; e.g., for floating-rate bonds you can cancel the last coupon by passing a null gearing.