QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
fixedratecoupon.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
5 Copyright (C) 2003, 2004, 2007 StatPro Italia srl
6 Copyright (C) 2007 Piter Dias
7 Copyright (C) 2010 Ferdinando Ametrano
8 Copyright (C) 2017 Joseph Jeisman
9 Copyright (C) 2017 Fabrice Lecuyer
10
11 This file is part of QuantLib, a free-software/open-source library
12 for financial quantitative analysts and developers - http://quantlib.org/
13
14 QuantLib is free software: you can redistribute it and/or modify it
15 under the terms of the QuantLib license. You should have received a
16 copy of the license along with this program; if not, please email
17 <quantlib-dev@lists.sf.net>. The license is also available online at
18 <http://quantlib.org/license.shtml>.
19
20 This program is distributed in the hope that it will be useful, but WITHOUT
21 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22 FOR A PARTICULAR PURPOSE. See the license for more details.
23*/
24
29#ifndef quantlib_fixed_rate_coupon_hpp
30#define quantlib_fixed_rate_coupon_hpp
31
32#include <ql/cashflows/coupon.hpp>
33#include <ql/patterns/visitor.hpp>
34#include <ql/interestrate.hpp>
35#include <ql/time/daycounter.hpp>
36#include <ql/time/schedule.hpp>
37
38namespace QuantLib {
39
41 class FixedRateCoupon : public Coupon {
42 public:
44
45 FixedRateCoupon(const Date& paymentDate,
47 Rate rate,
50 const Date& accrualEndDate,
51 const Date& refPeriodStart = Date(),
52 const Date& refPeriodEnd = Date(),
53 const Date& exCouponDate = Date());
54 FixedRateCoupon(const Date& paymentDate,
58 const Date& accrualEndDate,
59 const Date& refPeriodStart = Date(),
60 const Date& refPeriodEnd = Date(),
61 const Date& exCouponDate = Date());
63
65 void performCalculations() const override;
67
69 Real amount() const override;
71
73 Rate rate() const override { return rate_; }
74 InterestRate interestRate() const { return rate_; }
75 DayCounter dayCounter() const override { return rate_.dayCounter(); }
76 Real accruedAmount(const Date&) const override;
78
80 void accept(AcyclicVisitor&) override;
82 private:
84 mutable Real amount_;
85 };
86
87
88
91 public:
92 FixedRateLeg(const Schedule& schedule);
94 FixedRateLeg& withNotionals(const std::vector<Real>&);
96 const DayCounter& paymentDayCounter,
97 Compounding comp = Simple,
98 Frequency freq = Annual);
99 FixedRateLeg& withCouponRates(const std::vector<Rate>&,
100 const DayCounter& paymentDayCounter,
101 Compounding comp = Simple,
102 Frequency freq = Annual);
104 FixedRateLeg& withCouponRates(const std::vector<InterestRate>&);
111 const Calendar&,
113 bool endOfMonth = false);
114 operator Leg() const;
115 private:
117 std::vector<Real> notionals_;
118 std::vector<InterestRate> couponRates_;
127 };
128
130 auto* v1 = dynamic_cast<Visitor<FixedRateCoupon>*>(&v);
131 if (v1 != nullptr)
132 v1->visit(*this);
133 else
135 }
136
137}
138
139
140#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
calendar class
Definition: calendar.hpp:61
coupon accruing over a fixed period
Definition: coupon.hpp:39
const Date & accrualStartDate() const
start of the accrual period
Definition: coupon.hpp:104
void accept(AcyclicVisitor &) override
Definition: coupon.cpp:80
Date exCouponDate() const override
returns the date that the cash flow trades exCoupon
Definition: coupon.hpp:57
virtual Real nominal() const
Definition: coupon.hpp:100
const Date & accrualEndDate() const
end of the accrual period
Definition: coupon.hpp:108
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Coupon paying a fixed interest rate
InterestRate interestRate() const
void performCalculations() const override
Rate rate() const override
accrued rate
Real amount() const override
returns the amount of the cash flow
void accept(AcyclicVisitor &) override
DayCounter dayCounter() const override
day counter for accrual calculation
Real accruedAmount(const Date &) const override
accrued amount at the given date
helper class building a sequence of fixed rate coupons
BusinessDayConvention paymentAdjustment_
FixedRateLeg & withNotionals(Real)
BusinessDayConvention exCouponAdjustment_
std::vector< InterestRate > couponRates_
FixedRateLeg & withPaymentCalendar(const Calendar &)
std::vector< Real > notionals_
FixedRateLeg & withPaymentAdjustment(BusinessDayConvention)
FixedRateLeg & withCouponRates(Rate, const DayCounter &paymentDayCounter, Compounding comp=Simple, Frequency freq=Annual)
FixedRateLeg & withLastPeriodDayCounter(const DayCounter &)
FixedRateLeg & withFirstPeriodDayCounter(const DayCounter &)
FixedRateLeg & withPaymentLag(Natural lag)
FixedRateLeg & withExCouponPeriod(const Period &, const Calendar &, BusinessDayConvention, bool endOfMonth=false)
Concrete interest rate class.
const DayCounter & dayCounter() const
Payment schedule.
Definition: schedule.hpp:40
Visitor for a specific class
Definition: visitor.hpp:40
virtual void visit(T &)=0
Frequency
Frequency of events.
Definition: frequency.hpp:37
BusinessDayConvention
Business Day conventions.
@ Annual
once a year
Definition: frequency.hpp:39
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35
Compounding
Interest rate coumpounding rule.
Definition: compounding.hpp:32
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78