25#include <ql/cashflows/fixedratecoupon.hpp>
36 const Date& accrualStartDate,
37 const Date& accrualEndDate,
38 const Date& refPeriodStart,
39 const Date& refPeriodEnd,
40 const Date& exCouponDate)
41 :
Coupon(paymentDate, nominal, accrualStartDate, accrualEndDate,
42 refPeriodStart, refPeriodEnd, exCouponDate),
48 const Date& accrualStartDate,
49 const Date& accrualEndDate,
50 const Date& refPeriodStart,
51 const Date& refPeriodEnd,
52 const Date& exCouponDate)
60 rate_(
std::move(interestRate)) {}
93 : schedule_(schedule), paymentCalendar_(schedule.calendar()) {}
125 for (
Size i=0; i<rates.size(); ++i)
131 const vector<InterestRate>& interestRates) {
176 FixedRateLeg::operator
Leg()
const {
178 QL_REQUIRE(!couponRates_.empty(),
"no coupon rates given");
179 QL_REQUIRE(!notionals_.empty(),
"no notional given");
182 leg.reserve(schedule_.size()-1);
185 Date start = schedule_.date(0), end = schedule_.date(1);
186 Date paymentDate = paymentCalendar_.
advance(end, paymentLag_,
Days, paymentAdjustment_);
189 Real nominal = notionals_[0];
191 if (exCouponPeriod_ !=
Period())
193 exCouponDate = exCouponCalendar_.
advance(paymentDate,
196 exCouponEndOfMonth_);
198 Date ref = schedule_.hasTenor() &&
199 schedule_.hasIsRegular() && !schedule_.isRegular(1) ?
200 schedule_.calendar().
advance(end,
202 schedule_.businessDayConvention(),
203 schedule_.endOfMonth())
206 firstPeriodDC_.empty() ? rate.dayCounter()
208 rate.compounding(), rate.frequency());
209 leg.push_back(ext::shared_ptr<CashFlow>(
new
211 start, end, ref, end, exCouponDate)));
213 for (
Size i=2; i<schedule_.size()-1; ++i) {
214 start = end; end = schedule_.date(i);
215 Date paymentDate = paymentCalendar_.
advance(end, paymentLag_,
Days, paymentAdjustment_);
216 if (exCouponPeriod_ !=
Period())
218 exCouponDate = exCouponCalendar_.
advance(paymentDate,
221 exCouponEndOfMonth_);
223 if ((i-1) < couponRates_.size())
224 rate = couponRates_[i-1];
226 rate = couponRates_.back();
227 if ((i-1) < notionals_.size())
228 nominal = notionals_[i-1];
230 nominal = notionals_.back();
231 leg.push_back(ext::shared_ptr<CashFlow>(
new
233 start, end, start, end, exCouponDate)));
235 if (schedule_.size() > 2) {
237 Size N = schedule_.size();
238 start = end; end = schedule_.date(N-1);
239 Date paymentDate = paymentCalendar_.
advance(end, paymentLag_,
Days, paymentAdjustment_);
240 if (exCouponPeriod_ !=
Period())
242 exCouponDate = exCouponCalendar_.
advance(paymentDate,
245 exCouponEndOfMonth_);
247 if ((N-2) < couponRates_.size())
248 rate = couponRates_[N-2];
250 rate = couponRates_.back();
251 if ((N-2) < notionals_.size())
252 nominal = notionals_[N-2];
254 nominal = notionals_.back();
257 lastPeriodDC_ , rate.compounding(), rate.frequency() );
258 if ((schedule_.hasIsRegular() && schedule_.isRegular(N - 1)) ||
259 !schedule_.hasTenor()) {
260 leg.push_back(ext::shared_ptr<CashFlow>(
new
262 start, end, start, end, exCouponDate)));
267 schedule_.businessDayConvention(),
269 leg.push_back(ext::shared_ptr<CashFlow>(
new
271 start, end, start, ref, exCouponDate)));
bool tradingExCoupon(const Date &refDate=Date()) const
returns true if the cashflow is trading ex-coupon on the refDate
coupon accruing over a fixed period
virtual Real nominal() const
static Date endOfMonth(const Date &d)
last day of the month to which the given date belongs
static Date advance(const Date &d, Integer units, TimeUnit)
Coupon paying a fixed interest rate
void performCalculations() const override
Real amount() const override
returns the amount of the cash flow
Real accruedAmount(const Date &) const override
accrued amount at the given date
FixedRateCoupon(const Date &paymentDate, Real nominal, Rate rate, const DayCounter &dayCounter, const Date &accrualStartDate, const Date &accrualEndDate, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date(), const Date &exCouponDate=Date())
helper class building a sequence of fixed rate coupons
BusinessDayConvention paymentAdjustment_
FixedRateLeg & withNotionals(Real)
BusinessDayConvention exCouponAdjustment_
Calendar paymentCalendar_
std::vector< InterestRate > couponRates_
DayCounter firstPeriodDC_
FixedRateLeg & withPaymentCalendar(const Calendar &)
FixedRateLeg(const Schedule &schedule)
std::vector< Real > notionals_
FixedRateLeg & withPaymentAdjustment(BusinessDayConvention)
FixedRateLeg & withCouponRates(Rate, const DayCounter &paymentDayCounter, Compounding comp=Simple, Frequency freq=Annual)
FixedRateLeg & withLastPeriodDayCounter(const DayCounter &)
Calendar exCouponCalendar_
FixedRateLeg & withFirstPeriodDayCounter(const DayCounter &)
FixedRateLeg & withPaymentLag(Natural lag)
FixedRateLeg & withExCouponPeriod(const Period &, const Calendar &, BusinessDayConvention, bool endOfMonth=false)
Concrete interest rate class.
Real compoundFactor(Time t) const
compound factor implied by the rate compounded at time t.
virtual void calculate() const
Frequency
Frequency of events.
BusinessDayConvention
Business Day conventions.
unsigned QL_INTEGER Natural
positive integer
std::size_t Size
size of a container
Compounding
Interest rate coumpounding rule.
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.