26 QL_REQUIRE(
coupon_,
"AverageONIndexedCoupon required");
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 <<
")");
49 Date valuationDate = Settings::instance().evaluationDate();
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];
59 if (i < numPeriods && fixingDates[std::min(i, nCutoff)] == valuationDate) {
61 if (valuationDateFixing != Null<Real>()) {
62 accumulatedRate += valuationDateFixing * accrualFractions[i];
68 Handle<YieldTermStructure> projectionCurve =
overnightIndex_->forwardingTermStructure();
69 QL_REQUIRE(!projectionCurve.empty(),
70 "Null term structure set to this instance of " <<
overnightIndex_->name());
75 DiscountFactor startDiscount = projectionCurve->discount(startForecast);
76 DiscountFactor endDiscount = projectionCurve->discount(endForecast);
79 if (nCutoff < numPeriods) {
81 DiscountFactor discountCutoffDate = projectionCurve->discount(
coupon_->
valueDates()[nCutoff] + 1) /
88 accumulatedRate +=
log(startDiscount / endDiscount);
92 for (Size i = 0; i < numPeriods; ++i) {
93 accumulatedRate += fixings[i] * accrualFractions[i];
96 QL_FAIL(
"Invalid Approximation for AverageONIndexedCouponPricer");
Pricer for average overnight indexed coupons.
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
QuantLib::ext::shared_ptr< OvernightIndex > overnightIndex_
void initialize(const FloatingRateCoupon &coupon) override
const AverageONIndexedCoupon * coupon_
Approximation approximationType_
Rate swapletRate() const override
CompiledFormula log(CompiledFormula x)