@@ -277,6 +277,11 @@ CPILeg& CPILeg::withPaymentCalendar(const Calendar& cal) {
277277 return *this ;
278278}
279279
280+ CPILeg& CPILeg::withPaymentLag (Natural lag) {
281+ paymentLag_ = lag;
282+ return *this ;
283+ }
284+
280285CPILeg& CPILeg::withFixingDays (Natural fixingDays) {
281286 fixingDays_ = std::vector<Natural>(1 , fixingDays);
282287 return *this ;
@@ -366,7 +371,7 @@ CPILeg::operator Leg() const {
366371 for (Size i = 0 ; i < n; ++i) {
367372 refStart = start = schedule_.date (i);
368373 refEnd = end = schedule_.date (i + 1 );
369- Date paymentDate = paymentCalendar_.adjust (end, paymentAdjustment_);
374+ Date paymentDate = paymentCalendar_.advance (end, paymentLag_, Days , paymentAdjustment_);
370375
371376 Date exCouponDate;
372377 if (exCouponPeriod_ != Period ()) {
@@ -405,10 +410,13 @@ CPILeg::operator Leg() const {
405410 }
406411
407412 // in CPI legs you always have a notional flow of some sort
408- Date paymentDate = paymentCalendar_.adjust (schedule_.date (n), paymentAdjustment_);
409413
414+ // Previous implementations didn't differentiate the observation and payment dates
415+ Date observationDate = paymentCalendar_.adjust (schedule_.date (n), paymentAdjustment_);
416+ Date paymentDate = paymentCalendar_.advance (schedule_.date (n), paymentLag_, Days, paymentAdjustment_);
417+
410418 ext::shared_ptr<CPICashFlow> xnl = ext::make_shared<CPICashFlow>(
411- detail::get (notionals_, n, 0.0 ), index_, baseDate, baseCPI_, paymentDate , observationLag_,
419+ detail::get (notionals_, n, 0.0 ), index_, baseDate, baseCPI_, observationDate , observationLag_,
412420 observationInterpolation_, paymentDate, subtractInflationNominal_);
413421
414422 if (finalFlowCap_ == Null<Real>() && finalFlowFloor_ == Null<Real>()) {
0 commit comments