36 {
37
39 std::vector<Time> accrualFractions =
coupon_->
dt();
40 Size numPeriods = accrualFractions.size();
41 Real accumulatedRate = 0;
43 "rate cutoff (" <<
coupon_->
rateCutoff() <<
") must be less than number of fixings in period ("
44 << numPeriods << ")");
46
48 Size i = 0;
49 Date valuationDate = Settings::instance().evaluationDate();
50
51 while (i < numPeriods && fixingDates[std::min(i, nCutoff)] < valuationDate) {
52 Rate pastFixing =
overnightIndex_->pastFixing(fixingDates[std::min(i, nCutoff)]);
53 QL_REQUIRE(pastFixing != Null<Real>(),
54 "Missing " <<
overnightIndex_->name() <<
" fixing for " << fixingDates[std::min(i, nCutoff)]);
55 accumulatedRate += pastFixing * accrualFractions[i];
56 ++i;
57 }
58
59 if (i < numPeriods && fixingDates[std::min(i, nCutoff)] == valuationDate) {
61 if (valuationDateFixing != Null<Real>()) {
62 accumulatedRate += valuationDateFixing * accrualFractions[i];
63 ++i;
64 }
65 }
66
67 if (i < numPeriods) {
68 Handle<YieldTermStructure> projectionCurve =
overnightIndex_->forwardingTermStructure();
69 QL_REQUIRE(!projectionCurve.empty(),
70 "Null term structure set to this instance of " <<
overnightIndex_->name());
71
72
75 DiscountFactor startDiscount = projectionCurve->discount(startForecast);
76 DiscountFactor endDiscount = projectionCurve->discount(endForecast);
77
78
79 if (nCutoff < numPeriods) {
80
81 DiscountFactor discountCutoffDate = projectionCurve->discount(
coupon_->
valueDates()[nCutoff] + 1) /
83
84 endDiscount *=
86 }
87
88 accumulatedRate +=
log(startDiscount / endDiscount);
89 }
92 for (Size i = 0; i < numPeriods; ++i) {
93 accumulatedRate += fixings[i] * accrualFractions[i];
94 }
95 } else {
96 QL_FAIL("Invalid Approximation for AverageONIndexedCouponPricer");
97 }
98
101 return rate;
102}
Natural rateCutoff() const
rate cutoff associated with the coupon
const std::vector< Date > & valueDates() const
value dates for the rates to be averaged
const std::vector< Time > & dt() const
accrual periods for the averaging
const std::vector< Rate > & indexFixings() const
fixings to be averaged
const std::vector< Date > & fixingDates() const
fixing dates for the rates to be averaged
CompiledFormula log(CompiledFormula x)