QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
coupon.hpp
Go to the documentation of this file.
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
21/*! \file coupon.hpp
22 \brief Coupon accruing over a fixed period
23*/
24
25#ifndef quantlib_coupon_hpp
26#define quantlib_coupon_hpp
27
28#include <ql/cashflow.hpp>
29
30namespace QuantLib {
31
32 class DayCounter;
33
34 //! %coupon accruing over a fixed period
35 /*! This class implements part of the CashFlow interface but it is
36 still abstract and provides derived classes with methods for
37 accrual period calculations.
38 */
39 class Coupon : public CashFlow {
40 public:
41 /*! \warning the coupon does not adjust the payment date which
42 must already be a business day.
43 */
44 Coupon(const Date& paymentDate,
47 const Date& accrualEndDate,
48 const Date& refPeriodStart = Date(),
49 const Date& refPeriodEnd = Date(),
50 const Date& exCouponDate = Date());
51 //! \name Event interface
52 //@{
53 Date date() const override { return paymentDate_; }
54 //@}
55 //! \name CashFlow interface
56 //@{
57 Date exCouponDate() const override { return exCouponDate_; }
58 //@}
59 //! \name Inspectors
60 //@{
61 virtual Real nominal() const;
62 //! start of the accrual period
63 const Date& accrualStartDate() const;
64 //! end of the accrual period
65 const Date& accrualEndDate() const;
66 //! start date of the reference period
67 const Date& referencePeriodStart() const;
68 //! end date of the reference period
69 const Date& referencePeriodEnd() const;
70 //! accrual period as fraction of year
71 Time accrualPeriod() const;
72 //! accrual period in days
74 //! accrued rate
75 virtual Rate rate() const = 0;
76 //! day counter for accrual calculation
77 virtual DayCounter dayCounter() const = 0;
78 //! accrued period as fraction of year at the given date
79 Time accruedPeriod(const Date&) const;
80 //! accrued days at the given date
82 //! accrued amount at the given date
83 virtual Real accruedAmount(const Date&) const = 0;
84 //@}
85 //! \name Visitability
86 //@{
87 void accept(AcyclicVisitor&) override;
88 //@}
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
Base class for cash flows.
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