QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
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:
78 Natural settlementDays,
79 Real faceAmount,
80 Schedule schedule,
81 const std::vector<Rate>& coupons,
82 const DayCounter& dayCounter,
83 BusinessDayConvention paymentConv = Following,
84 Real redemption = 100.0,
85 const Date& issueDate = Date(),
86 const Calendar& paymentCalendar = Calendar(),
87 const Period& exCouponPeriod = Period(),
88 const Calendar& exCouponCalendar = Calendar(),
89 BusinessDayConvention exCouponConvention = Unadjusted,
90 bool exCouponEndOfMonth = false,
92
93 //! \name Visitability
94 //@{
95 void accept(AcyclicVisitor&) override;
96 //@}
97 };
98
99
100 //! CPI bond helper for curve bootstrap
101 class CPIBondHelper : public BondHelper {
102 public:
103 CPIBondHelper(const Handle<Quote>& price,
104 Natural settlementDays,
105 Real faceAmount,
106 bool growthOnly,
107 Real baseCPI,
108 const Period& observationLag,
109 const ext::shared_ptr<ZeroInflationIndex>& cpiIndex,
110 CPI::InterpolationType observationInterpolation,
111 Schedule schedule,
112 const std::vector<Rate>& fixedRate,
113 const DayCounter& accrualDayCounter,
114 BusinessDayConvention paymentConvention = Following,
115 const Date& issueDate = Date(),
116 const Calendar& paymentCalendar = Calendar(),
117 const Period& exCouponPeriod = Period(),
118 const Calendar& exCouponCalendar = Calendar(),
119 BusinessDayConvention exCouponConvention = Unadjusted,
120 bool exCouponEndOfMonth = false,
122
123 //! \name Visitability
124 //@{
125 void accept(AcyclicVisitor&) override;
126 //@}
127 };
128
129
130 // inline
131
132 inline ext::shared_ptr<Bond> BondHelper::bond() const {
133 return bond_;
134 }
135
137 return priceType_;
138 }
139
140
141}
142
143#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
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
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:37
deposit, FRA, futures, and various swap rate helpers
InterpolationType
when you observe an index, how do you interpolate between fixings?