#include <qle/cashflows/zerofixedcoupon.hpp>
|
| ZeroFixedCoupon (const Date &paymentDate, double notional, double rate, const DayCounter &dc, const std::vector< Date > &dates, const Compounding &comp, bool subtractNotional) |
|
|
Real | amount () const override |
|
Real | nominal () const override |
|
Real | rate () const override |
|
DayCounter | dayCounter () const override |
|
Real | accruedAmount (const Date &accrualEnd) const override |
|
Definition at line 40 of file zerofixedcoupon.hpp.
◆ ZeroFixedCoupon()
ZeroFixedCoupon |
( |
const Date & |
paymentDate, |
|
|
double |
notional, |
|
|
double |
rate, |
|
|
const DayCounter & |
dc, |
|
|
const std::vector< Date > & |
dates, |
|
|
const Compounding & |
comp, |
|
|
bool |
subtractNotional |
|
) |
| |
Definition at line 23 of file zerofixedcoupon.cpp.
29 :
30 Coupon(paymentDate, notional, dates.front(), dates.back()),
33 {
34
35 QL_REQUIRE(
comp_ == QuantLib::Compounded ||
comp_ == QuantLib::Simple,
36 "Compounding method " <<
comp_ <<
" not supported");
37
38 QL_REQUIRE(
dates_.size() >= 2,
"Number of schedule dates expected at least 2, got " <<
dates_.size());
39
41
42 }
std::vector< Date > dates_
Real accruedAmount(const Date &accrualEnd) const override
Real rate() const override
◆ amount()
◆ nominal()
◆ rate()
◆ dayCounter()
DayCounter dayCounter |
( |
| ) |
const |
|
override |
◆ accruedAmount()
Real accruedAmount |
( |
const Date & |
accrualEnd | ) |
const |
|
override |
Definition at line 52 of file zerofixedcoupon.cpp.
52 {
53
54
55 if(
dates_.front() > accrualEnd ||
dates_.back() < accrualEnd)
56 return 0.0;
57
58 double totalDCF = 0.0;
59 double compoundFactor = 1.0;
60
61
62
63
64
65
66
67
68 for (Size i = 0; i <
dates_.size() - 1; i++) {
69
70 Date startDate =
dates_[i];
71 Date endDate =
dates_[i+1];
72
73 if(startDate > accrualEnd)
74 break;
75
76 if(endDate > accrualEnd)
77 endDate = accrualEnd;
78
79 double dcf =
dc_.yearFraction(startDate, endDate);
80
81 if (
comp_ == QuantLib::Simple)
82 compoundFactor *= (1 +
rate_ * dcf);
83
84 totalDCF += dcf;
85 }
86
87 if (
comp_ == QuantLib::Compounded)
88 compoundFactor =
pow(1.0 +
rate_, totalDCF);
89
91
92
93
94}
CompiledFormula pow(CompiledFormula x, const CompiledFormula &y)
◆ accept()
void accept |
( |
AcyclicVisitor & |
v | ) |
|
|
override |
Definition at line 98 of file zerofixedcoupon.cpp.
98 {
99 Visitor<ZeroFixedCoupon>* v1 = dynamic_cast<Visitor<ZeroFixedCoupon>*>(&v);
100 if (v1 != 0)
101 v1->visit(*this);
102 else
103 Coupon::accept(v);
104}
◆ notional_
◆ rate_
◆ dc_
◆ dates_
◆ comp_
◆ subtractNotional_
◆ amount_