36 Real compoundFactor = 1.0;
37 Date today = Settings::instance().evaluationDate();
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]);
48 if (i < n && fixingDates[i] == today) {
50 Rate pastFixing = IndexManager::instance().getHistory(
index_->name())[fixingDates[i]];
51 if (pastFixing != Null<Real>()) {
52 compoundFactor *=
pow(1.0 + pastFixing, dt[i]);
62 Handle<YieldTermStructure> curve =
index_->forwardingTermStructure();
63 QL_REQUIRE(!curve.empty(),
"BRLCdiCouponPricer needs the index to have a forwarding term structure");
66 DiscountFactor startDiscount = curve->discount(dates[i]);
67 DiscountFactor endDiscount = curve->discount(dates[n]);
69 compoundFactor *= startDiscount / endDiscount;
79 couponQl_ =
dynamic_cast<const QuantLib::OvernightIndexedCoupon*
>(&coupon);
81 QL_REQUIRE(
couponQl_ ||
couponQle_,
"BRLCdiCouponPricer expects an OvernightIndexedCoupon");
84 index_ = QuantLib::ext::dynamic_pointer_cast<BRLCdi>(index);
85 QL_REQUIRE(
index_,
"BRLCdiCouponPricer expects the coupon's index to be BRLCdi");
91 QL_FAIL(
"capletPrice not implemented for BRLCdiCouponPricer");
95 QL_FAIL(
"capletRate not implemented for BRLCdiCouponPricer");
99 QL_FAIL(
"floorletPrice not implemented for BRLCdiCouponPricer");
103 QL_FAIL(
"floorletRate not implemented for BRLCdiCouponPricer");
Coupon pricer for a BRL CDI coupon.
QuantLib::ext::shared_ptr< BRLCdi > index_
The index underlying the coupon to be priced.
virtual QuantLib::Real capletPrice(QuantLib::Rate effectiveCap) const override
const QuantExt::OvernightIndexedCoupon * couponQle_
virtual QuantLib::Real floorletPrice(QuantLib::Rate effectiveFloor) const override
virtual QuantLib::Rate floorletRate(QuantLib::Rate effectiveFloor) const override
virtual QuantLib::Rate capletRate(QuantLib::Rate effectiveCap) const override
const QuantLib::OvernightIndexedCoupon * couponQl_
virtual QuantLib::Rate swapletRate() const override
virtual void initialize(const QuantLib::FloatingRateCoupon &coupon) override
virtual QuantLib::Real swapletPrice() const override
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)