QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
coupon.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
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
25#ifndef quantlib_coupon_hpp
26#define quantlib_coupon_hpp
27
28#include <ql/cashflow.hpp>
29
30namespace QuantLib {
31
32 class DayCounter;
33
35
39 class Coupon : public CashFlow {
40 public:
44 Coupon(const Date& paymentDate,
47 const Date& accrualEndDate,
48 const Date& refPeriodStart = Date(),
49 const Date& refPeriodEnd = Date(),
50 const Date& exCouponDate = Date());
52
53 Date date() const override { return paymentDate_; }
55
57 Date exCouponDate() const override { return exCouponDate_; }
59
61 virtual Real nominal() const;
63 const Date& accrualStartDate() const;
65 const Date& accrualEndDate() const;
67 const Date& referencePeriodStart() const;
69 const Date& referencePeriodEnd() const;
71 Time accrualPeriod() const;
75 virtual Rate rate() const = 0;
77 virtual DayCounter dayCounter() const = 0;
79 Time accruedPeriod(const Date&) const;
83 virtual Real accruedAmount(const Date&) const = 0;
85
87 void accept(AcyclicVisitor&) override;
89 protected:
95 };
96
97
98 // inline definitions
99
100 inline Real Coupon::nominal() const {
101 return nominal_;
102 }
103
104 inline const Date& Coupon::accrualStartDate() const {
105 return accrualStartDate_;
106 }
107
108 inline const Date& Coupon::accrualEndDate() const {
109 return accrualEndDate_;
110 }
111
112 inline const Date& Coupon::referencePeriodStart() const {
113 return refPeriodStart_;
114 }
115
116 inline const Date& Coupon::referencePeriodEnd() const {
117 return refPeriodEnd_;
118 }
119
120}
121
122#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Base class for cash flows.
Definition: cashflow.hpp:40
coupon accruing over a fixed period
Definition: coupon.hpp:39
virtual Rate rate() const =0
accrued rate
Date::serial_type accrualDays() const
accrual period in days
Definition: coupon.cpp:52
const Date & referencePeriodEnd() const
end date of the reference period
Definition: coupon.hpp:116
Date paymentDate_
Definition: coupon.hpp:90
Date exCouponDate_
Definition: coupon.hpp:93
Date refPeriodEnd_
Definition: coupon.hpp:92
const Date & accrualStartDate() const
start of the accrual period
Definition: coupon.hpp:104
void accept(AcyclicVisitor &) override
Definition: coupon.cpp:80
Date accrualStartDate_
Definition: coupon.hpp:92
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
Date refPeriodStart_
Definition: coupon.hpp:92
virtual DayCounter dayCounter() const =0
day counter for accrual calculation
const Date & accrualEndDate() const
end of the accrual period
Definition: coupon.hpp:108
Date accrualEndDate_
Definition: coupon.hpp:92
Real accrualPeriod_
Definition: coupon.hpp:94
Date date() const override
Definition: coupon.hpp:53
virtual Real accruedAmount(const Date &) const =0
accrued amount at the given date
Time accruedPeriod(const Date &) const
accrued period as fraction of year at the given date
Definition: coupon.cpp:57
Date::serial_type accruedDays(const Date &) const
accrued days at the given date
Definition: coupon.cpp:71
Time accrualPeriod() const
accrual period as fraction of year
Definition: coupon.cpp:44
const Date & referencePeriodStart() const
start date of the reference period
Definition: coupon.hpp:112
Concrete date class.
Definition: date.hpp:125
std::int_fast32_t serial_type
serial number type
Definition: date.hpp:128
day counter class
Definition: daycounter.hpp:44
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35