Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ql/cashflows/overnightindexedcoupon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ const std::optional<Integer>& roundingPrecision)
// if lockout days are defined, we need to ensure that
// the lockout period is covered by the value dates
tmpEndDate = fixingCal.adjust(rateCalcEndDate, Following);
const Date tmpLockoutDate = fixingCal.advance(rateCalcEndDate,
Date tmpLockoutDate = fixingCal.advance(rateCalcEndDate,
-std::max<Integer>(lockoutDays_, 1), Days);
// Retain the observation immediately before the lockout period.
// The last lockoutDays_ fixings repeat this anchor fixing.
if (lockoutDays_ != 0)
tmpLockoutDate = fixingCal.advance(tmpLockoutDate, -1, Days);
Date nextValueDate = tmpLockoutDate > valueDates_.back()
? tmpLockoutDate
: fixingCal.advance(valueDates_.back(), 1, Days);
Expand Down
13 changes: 10 additions & 3 deletions test-suite/overnightindexedcoupon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,14 +1029,21 @@ BOOST_AUTO_TEST_CASE(testOvernightLegNPV) {

Handle<YieldTermStructure> discountCurve(flatRate(0.0015, Actual360()));

// Calculate NPV
Real expectedNpv = 34883.949669756257;
// Reference from independent daily SOFR deposit products with the three-day
// lockout anchored immediately before the frozen tail, then payment discounting.
const Real expectedNpv = 34638.786842594876;
Real npv = 0.0;
for (const auto& cf : leg) {
npv += cf->amount() * discountCurve->discount(cf->date());
}

CHECK_OIS_COUPON_RESULT("OvernightLeg NPV", npv, expectedNpv, 1e-8);
Leg denseLeg = vars.makeLeg(Null<Natural>(), 3, false, false, RateAveraging::Compound);
Real denseNpv = 0.0;
for (const auto& cf : denseLeg)
denseNpv += cf->amount() * discountCurve->discount(cf->date());

QL_CHECK_SMALL(npv - expectedNpv, 1e-8);
QL_CHECK_SMALL(denseNpv - expectedNpv, 1e-8);
}

BOOST_AUTO_TEST_CASE(testOvernightLegWithCapsAndFloors) {
Expand Down