30 {
31
34 Size n = dt.size();
35 Size i = 0;
36 Real compoundFactor = 1.0;
37 Date today = Settings::instance().evaluationDate();
38
39
40 while (i < n && fixingDates[i] < today) {
41 Rate pastFixing = IndexManager::instance().getHistory(
index_->name())[fixingDates[i]];
42 QL_REQUIRE(pastFixing != Null<Real>(),
"Missing " <<
index_->name() <<
" fixing for " << fixingDates[i]);
43 compoundFactor *=
pow(1.0 + pastFixing, dt[i]);
44 ++i;
45 }
46
47
48 if (i < n && fixingDates[i] == today) {
49 try {
50 Rate pastFixing = IndexManager::instance().getHistory(
index_->name())[fixingDates[i]];
51 if (pastFixing != Null<Real>()) {
52 compoundFactor *=
pow(1.0 + pastFixing, dt[i]);
53 ++i;
54 }
55 } catch (Error&) {
56 }
57 }
58
59
60
61 if (i < n) {
62 Handle<YieldTermStructure> curve =
index_->forwardingTermStructure();
63 QL_REQUIRE(!curve.empty(), "BRLCdiCouponPricer needs the index to have a forwarding term structure");
64
66 DiscountFactor startDiscount = curve->discount(dates[i]);
67 DiscountFactor endDiscount = curve->discount(dates[n]);
68
69 compoundFactor *= startDiscount / endDiscount;
70 }
71
75}
QuantLib::ext::shared_ptr< BRLCdi > index_
The index underlying the coupon to be priced.
const QuantExt::OvernightIndexedCoupon * couponQle_
const QuantLib::OvernightIndexedCoupon * couponQl_
const std::vector< Date > & valueDates() const
value dates for the rates to be compounded
const std::vector< Time > & dt() const
accrual (compounding) periods
const std::vector< Date > & fixingDates() const
fixing dates for the rates to be compounded
CompiledFormula pow(CompiledFormula x, const CompiledFormula &y)