QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
bondhelpers.hpp
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
26#ifndef quantlib_bond_helpers_hpp
27#define quantlib_bond_helpers_hpp
28
29#include <ql/termstructures/yield/ratehelpers.hpp>
30#include <ql/instruments/bonds/fixedratebond.hpp>
31#include <ql/instruments/bonds/cpibond.hpp>
32#include <ql/cashflows/cpicoupon.hpp>
33
34namespace QuantLib {
35
37
40 class BondHelper : public RateHelper {
41 public:
48 BondHelper(const Handle<Quote>& price,
49 const ext::shared_ptr<Bond>& bond,
51
53
54 Real impliedQuote() const override;
57
59 ext::shared_ptr<Bond> bond() const;
60
63
65 void accept(AcyclicVisitor&) override;
67 protected:
68 ext::shared_ptr<Bond> bond_;
71 };
72
73
76 public:
78 Natural settlementDays,
79 Real faceAmount,
80 const 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
94
95 ext::shared_ptr<FixedRateBond> fixedRateBond() const;
97
99 void accept(AcyclicVisitor&) override;
101 protected:
102 ext::shared_ptr<FixedRateBond> fixedRateBond_;
103 };
104
105
107 class CPIBondHelper : public BondHelper {
108 public:
109 CPIBondHelper(const Handle<Quote>& price,
110 Natural settlementDays,
111 Real faceAmount,
112 bool growthOnly,
113 Real baseCPI,
114 const Period& observationLag,
115 const ext::shared_ptr<ZeroInflationIndex>& cpiIndex,
116 CPI::InterpolationType observationInterpolation,
117 const Schedule& schedule,
118 const std::vector<Rate>& fixedRate,
119 const DayCounter& accrualDayCounter,
120 BusinessDayConvention paymentConvention = Following,
121 const Date& issueDate = Date(),
122 const Calendar& paymentCalendar = Calendar(),
123 const Period& exCouponPeriod = Period(),
124 const Calendar& exCouponCalendar = Calendar(),
125 BusinessDayConvention exCouponConvention = Unadjusted,
126 bool exCouponEndOfMonth = false,
128
130
131 ext::shared_ptr<CPIBond> cpiBond() const;
133
135 void accept(AcyclicVisitor&) override;
137 protected:
138 ext::shared_ptr<CPIBond> cpiBond_;
139 };
140
141
142 // inline
143
144 inline ext::shared_ptr<Bond> BondHelper::bond() const {
145 return bond_;
146 }
147
149 return priceType_;
150 }
151
152 inline ext::shared_ptr<FixedRateBond>
154 return fixedRateBond_;
155 }
156
157 inline ext::shared_ptr<CPIBond>
159 return cpiBond_;
160 }
161
162}
163
164#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.
ext::shared_ptr< CPIBond > cpiBond_
void accept(AcyclicVisitor &) override
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
ext::shared_ptr< FixedRateBond > fixedRateBond_
Shared handle to an observable.
Definition: handle.hpp:41
Relinkable handle to an observable.
Definition: handle.hpp:112
Payment schedule.
Definition: schedule.hpp:40
Interest-rate term structure.
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
InterpolationType
when you observe an index, how do you interpolate between fixings?