34 {
35
36 BOOST_TEST_MESSAGE("Testing QuantExt::CPILeg for payment lag...");
37
38 Date evaluationDate(6, October, 2023);
39 Settings::instance().evaluationDate() = evaluationDate;
40 Calendar calendar = WeekendsOnly();
41 DayCounter dayCounter = ActualActual(ActualActual::ISDA);
42
43 Date startDate(6, October, 2023);
44 Date endDate(6, October, 2026);
45 Schedule fixedSchedule = MakeSchedule()
46 .from(startDate)
47 .to(endDate)
48 .withTenor(Period(6, Months))
49 .withCalendar(calendar)
50 .withConvention(ModifiedFollowing)
51 .backwards();
52
53 auto flatYts = ext::shared_ptr<YieldTermStructure>(new FlatForward(evaluationDate, 0.025, dayCounter));
54 RelinkableHandle<YieldTermStructure> yTS(flatYts);
55
56 auto ukrpi = ext::make_shared<UKRPI>();
57 Leg cpiLeg =
QuantExt::CPILeg(fixedSchedule, ukrpi, yTS, 100, Period(3, Months))
62
63 for (auto& coupon : cpiLeg) {
64 if (auto cpiCoupon = ext::dynamic_pointer_cast<CPICoupon>(coupon))
65
66 BOOST_CHECK_EQUAL(cpiCoupon->date(), cpiCoupon->accrualEndDate() + 2 * Days);
67 else if (auto cpiNotionalCashflow = ext::dynamic_pointer_cast<CPICashFlow>(coupon))
68
69 BOOST_CHECK_EQUAL(cpiNotionalCashflow->date(), fixedSchedule.endDate() + 2 * Days);
70 }
71}
Helper class building a sequence of capped/floored CPI coupons.
CPILeg & withNotionals(Real notional)
CPILeg & withFixedRates(Real fixedRate)
CPILeg & withPaymentCalendar(const Calendar &)
CPILeg & withPaymentLag(Natural lag)