QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
bondhelpers.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) 2005 Toyin Akin
5 Copyright (C) 2007, 2009 StatPro Italia srl
6 Copyright (C) 2008 Ferdinando Ametrano
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
22/*! \file bondhelpers.hpp
23 \brief bond rate helpers
24*/
25
26#ifndef quantlib_bond_helpers_hpp
27#define quantlib_bond_helpers_hpp
28
33
34namespace QuantLib {
35
36 //! Bond helper for curve bootstrap
37 /*! \warning This class assumes that the reference date
38 does not change between calls of setTermStructure().
39 */
40 class BondHelper : public RateHelper {
41 public:
42 /*! \warning Setting a pricing engine to the passed bond from
43 external code will cause the bootstrap to fail or
44 to give wrong results. It is advised to discard
45 the bond after creating the helper, so that the
46 helper has sole ownership of it.
47 */
48 BondHelper(const Handle<Quote>& price,
49 const ext::shared_ptr<Bond>& bond,
51
52 //! \name RateHelper interface
53 //@{
54 Real impliedQuote() const override;
56 //@}
57 //! \name Additional inspectors
58 //@{
59 ext::shared_ptr<Bond> bond() const;
60
62 //@}
63 //! \name Visitability
64 //@{
65 void accept(AcyclicVisitor&) override;
66 //@}
67 protected:
68 ext::shared_ptr<Bond> bond_;
71 };
72
73
74 //! Fixed-coupon bond helper for curve bootstrap
76 public:
77 // needed to avoid warning about deprecated data member;
78 // it can be removed once the latter is gone.
80 ~FixedRateBondHelper() override = default;
82
84 Natural settlementDays,
85 Real faceAmount,
86 Schedule schedule,
87 const std::vector<Rate>& coupons,
88 const DayCounter& dayCounter,
89 BusinessDayConvention paymentConv = Following,
90 Real redemption = 100.0,
91 const Date& issueDate = Date(),
92 const Calendar& paymentCalendar = Calendar(),
93 const Period& exCouponPeriod = Period(),
94 const Calendar& exCouponCalendar = Calendar(),
95 BusinessDayConvention exCouponConvention = Unadjusted,
96 bool exCouponEndOfMonth = false,
98
99 /*! \deprecated Do not use; this method is broken and will be removed.
100 Deprecated in version 1.34.
101 */
102 [[deprecated("Do not use; this method is broken and will be removed.")]]
103 ext::shared_ptr<FixedRateBond> fixedRateBond() const {
105 return fixedRateBond_;
107 }
108
109 //! \name Visitability
110 //@{
111 void accept(AcyclicVisitor&) override;
112 //@}
113 protected:
114 /*! \deprecated Do not use; this pointer is always null.
115 Deprecated in version 1.34.
116 */
117 [[deprecated("Do not use; this pointer is always null.")]]
118 ext::shared_ptr<FixedRateBond> fixedRateBond_;
119 };
120
121
122 //! CPI bond helper for curve bootstrap
123 class CPIBondHelper : public BondHelper {
124 public:
125 // needed to avoid warning about deprecated data member;
126 // it can be removed once the latter is gone.
128 ~CPIBondHelper() override = default;
130
131 CPIBondHelper(const Handle<Quote>& price,
132 Natural settlementDays,
133 Real faceAmount,
134 bool growthOnly,
135 Real baseCPI,
136 const Period& observationLag,
137 const ext::shared_ptr<ZeroInflationIndex>& cpiIndex,
138 CPI::InterpolationType observationInterpolation,
139 Schedule schedule,
140 const std::vector<Rate>& fixedRate,
141 const DayCounter& accrualDayCounter,
142 BusinessDayConvention paymentConvention = Following,
143 const Date& issueDate = Date(),
144 const Calendar& paymentCalendar = Calendar(),
145 const Period& exCouponPeriod = Period(),
146 const Calendar& exCouponCalendar = Calendar(),
147 BusinessDayConvention exCouponConvention = Unadjusted,
148 bool exCouponEndOfMonth = false,
150
151 /*! \deprecated Do not use; this method is broken and will be removed.
152 Deprecated in version 1.34.
153 */
154 [[deprecated("Do not use; this method is broken and will be removed.")]]
155 ext::shared_ptr<CPIBond> cpiBond() const {
157 return cpiBond_;
159 }
160
161 //! \name Visitability
162 //@{
163 void accept(AcyclicVisitor&) override;
164 //@}
165 protected:
166 /*! \deprecated Do not use; this pointer is always null.
167 Deprecated in version 1.34.
168 */
169 [[deprecated("Do not use; this pointer is always null.")]]
170 ext::shared_ptr<CPIBond> cpiBond_;
171 };
172
173
174 // inline
175
176 inline ext::shared_ptr<Bond> BondHelper::bond() const {
177 return bond_;
178 }
179
181 return priceType_;
182 }
183
184
185}
186
187#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Bond helper for curve bootstrap.
Definition: bondhelpers.hpp:40
Bond::Price::Type priceType_
Definition: bondhelpers.hpp:70
void setTermStructure(YieldTermStructure *) override
Definition: bondhelpers.cpp:44
RelinkableHandle< YieldTermStructure > termStructureHandle_
Definition: bondhelpers.hpp:69
Bond::Price::Type priceType() const
ext::shared_ptr< Bond > bond() const
void accept(AcyclicVisitor &) override
Definition: bondhelpers.cpp:72
Real impliedQuote() const override
Definition: bondhelpers.cpp:53
ext::shared_ptr< Bond > bond_
Definition: bondhelpers.hpp:68
Base helper class for bootstrapping.
CPI bond helper for curve bootstrap.
void accept(AcyclicVisitor &) override
ext::shared_ptr< CPIBond > cpiBond_
QL_DEPRECATED_DISABLE_WARNING ~CPIBondHelper() override=default
ext::shared_ptr< CPIBond > cpiBond() const
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Fixed-coupon bond helper for curve bootstrap.
Definition: bondhelpers.hpp:75
void accept(AcyclicVisitor &) override
ext::shared_ptr< FixedRateBond > fixedRateBond() const
QL_DEPRECATED_DISABLE_WARNING ~FixedRateBondHelper() override=default
ext::shared_ptr< FixedRateBond > fixedRateBond_
Shared handle to an observable.
Definition: handle.hpp:41
Relinkable handle to an observable.
Definition: handle.hpp:117
Payment schedule.
Definition: schedule.hpp:40
Interest-rate term structure.
zero-inflation-indexed-ratio-with-base bond
Coupon paying a zero-inflation index.
fixed-rate bond
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Definition: any.hpp:35
#define QL_DEPRECATED_DISABLE_WARNING
Definition: qldefines.hpp:216
#define QL_DEPRECATED_ENABLE_WARNING
Definition: qldefines.hpp:217
deposit, FRA, futures, and various swap rate helpers
InterpolationType
when you observe an index, how do you interpolate between fixings?