27 const std::vector<Date>& dates,
28 const Compounding& comp,
29 bool subtractNotional) :
30 Coupon(paymentDate, notional, dates.front(), dates.back()),
31 notional_(notional), rate_(rate), dc_(dc), dates_(dates),
32 comp_(comp), subtractNotional_(subtractNotional)
35 QL_REQUIRE(
comp_ == QuantLib::Compounded ||
comp_ == QuantLib::Simple,
36 "Compounding method " <<
comp_ <<
" not supported");
38 QL_REQUIRE(
dates_.size() >= 2,
"Number of schedule dates expected at least 2, got " <<
dates_.size());
55 if(
dates_.front() > accrualEnd ||
dates_.back() < accrualEnd)
58 double totalDCF = 0.0;
59 double compoundFactor = 1.0;
68 for (Size i = 0; i <
dates_.size() - 1; i++) {
70 Date startDate =
dates_[i];
71 Date endDate =
dates_[i+1];
73 if(startDate > accrualEnd)
76 if(endDate > accrualEnd)
79 double dcf =
dc_.yearFraction(startDate, endDate);
81 if (
comp_ == QuantLib::Simple)
82 compoundFactor *= (1 +
rate_ * dcf);
87 if (
comp_ == QuantLib::Compounded)
88 compoundFactor =
pow(1.0 +
rate_, totalDCF);
99 Visitor<ZeroFixedCoupon>* v1 =
dynamic_cast<Visitor<ZeroFixedCoupon>*
>(&v);
ZeroFixedCoupon(const Date &paymentDate, double notional, double rate, const DayCounter &dc, const std::vector< Date > &dates, const Compounding &comp, bool subtractNotional)
std::vector< Date > dates_
Real amount() const override
void accept(AcyclicVisitor &) override
Real nominal() const override
DayCounter dayCounter() const override
Real accruedAmount(const Date &accrualEnd) const override
Real rate() const override
CompiledFormula pow(CompiledFormula x, const CompiledFormula &y)
Nominal flow associated with a floating annuity coupon.