QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
callablebond.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 Allen Kuo
5 Copyright (C) 2017 BN Algorithms Ltd
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_callable_bond_hpp
26#define quantlib_callable_bond_hpp
27
28#include <ql/instruments/bond.hpp>
29#include <ql/pricingengine.hpp>
30#include <ql/instruments/callabilityschedule.hpp>
31#include <ql/termstructures/yieldtermstructure.hpp>
32#include <ql/handle.hpp>
33#include <ql/quotes/simplequote.hpp>
34
35namespace QuantLib {
36
37 class Schedule;
38 class DayCounter;
39
41
53 class CallableBond : public Bond {
54 public:
55 class arguments;
56 class results;
57 class engine;
58
60
61
63 return putCallSchedule_;
64 }
66
68
69
75 const Bond::Price& targetPrice,
76 const Handle<YieldTermStructure>& discountCurve,
77 Real accuracy,
78 Size maxEvaluations,
79 Volatility minVol,
80 Volatility maxVol) const;
81
83
89 const Handle<YieldTermStructure>& engineTS,
90 const DayCounter& dayCounter,
91 Compounding compounding,
92 Frequency frequency,
94 Real accuracy = 1.0e-10,
95 Size maxIterations = 100,
96 Rate guess = 0.0);
97
102 const Handle<YieldTermStructure>& engineTS,
103 const DayCounter& dayCounter,
104 Compounding compounding,
105 Frequency frequency,
107
112 const Handle<YieldTermStructure>& engineTS,
113 const DayCounter& dayCounter,
114 Compounding compounding,
115 Frequency frequency,
116 Real bump=2e-4);
117
122 const Handle<YieldTermStructure>& engineTS,
123 const DayCounter& dayCounter,
124 Compounding compounding,
125 Frequency frequency,
126 Real bump=2e-4);
128
129 void setupArguments(PricingEngine::arguments* args) const override;
130
131 protected:
133 const Date& maturityDate,
134 const Calendar& calendar,
135 DayCounter paymentDayCounter,
136 Real faceAmount,
137 const Date& issueDate = Date(),
138 CallabilitySchedule putCallSchedule = CallabilitySchedule());
139
144 // helper class for Black implied volatility calculation
145 class ImpliedVolHelper;
146 // helper class for option adjusted spread calculations
147 class NPVSpreadHelper;
148
149 private:
150 /* Used internally.
151 same as Bond::accruedAmount() but with enable early
152 payments true. Forces accrued to be calculated in a
153 consistent way for future put/ call dates, which can be
154 problematic in lattice engines when option dates are also
155 coupon dates.
156 */
157 Real accrued(Date settlement) const;
158 };
159
161 public:
162 arguments() = default;
163 std::vector<Date> couponDates;
164 std::vector<Real> couponAmounts;
173 std::vector<Real> callabilityPrices;
174 std::vector<Date> callabilityDates;
179 void validate() const override;
180 };
181
184 public:
185 // no extra results set yet
186 };
187
190 : public GenericEngine<CallableBond::arguments,
191 CallableBond::results> {};
192
193
195
200 public:
202 Real faceAmount,
203 const Schedule& schedule,
204 const std::vector<Rate>& coupons,
205 const DayCounter& accrualDayCounter,
206 BusinessDayConvention paymentConvention = Following,
207 Real redemption = 100.0,
208 const Date& issueDate = Date(),
209 const CallabilitySchedule& putCallSchedule = {},
210 const Period& exCouponPeriod = Period(),
211 const Calendar& exCouponCalendar = Calendar(),
212 BusinessDayConvention exCouponConvention = Unadjusted,
213 bool exCouponEndOfMonth = false);
214 };
215
217
222 public:
224 Real faceAmount,
225 const Calendar& calendar,
226 const Date& maturityDate,
227 const DayCounter& dayCounter,
228 BusinessDayConvention paymentConvention = Following,
229 Real redemption = 100.0,
230 const Date& issueDate = Date(),
231 const CallabilitySchedule& putCallSchedule = {});
232 };
233
234}
235
236#endif
Bond price information.
Definition: bond.hpp:62
Base bond class.
Definition: bond.hpp:59
Real cleanPrice() const
theoretical clean price
Definition: bond.cpp:174
Natural settlementDays() const
Definition: bond.hpp:318
const Calendar & calendar() const
Definition: bond.hpp:322
Date issueDate() const
Definition: bond.hpp:338
const ext::shared_ptr< CashFlow > & redemption() const
Definition: bond.cpp:140
Date maturityDate() const
Definition: bond.cpp:150
Date settlementDate(Date d=Date()) const
Definition: bond.cpp:161
calendar class
Definition: calendar.hpp:61
std::vector< Date > callabilityDates
Real redemption
redemption = face amount * redemption / 100.
std::vector< Real > callabilityPrices
bond full/dirty/cash prices
void validate() const override
CallabilitySchedule putCallSchedule
base class for callable fixed rate bond engine
results for a callable bond calculation
Callable bond base class.
CallabilitySchedule putCallSchedule_
Real accrued(Date settlement) const
Real effectiveDuration(Real oas, const Handle< YieldTermStructure > &engineTS, const DayCounter &dayCounter, Compounding compounding, Frequency frequency, Real bump=2e-4)
Spread OAS(Real cleanPrice, const Handle< YieldTermStructure > &engineTS, const DayCounter &dayCounter, Compounding compounding, Frequency frequency, Date settlementDate=Date(), Real accuracy=1.0e-10, Size maxIterations=100, Rate guess=0.0)
Calculate the Option Adjusted Spread (OAS)
const CallabilitySchedule & callability() const
return the bond's put/call schedule
Real effectiveConvexity(Real oas, const Handle< YieldTermStructure > &engineTS, const DayCounter &dayCounter, Compounding compounding, Frequency frequency, Real bump=2e-4)
void setupArguments(PricingEngine::arguments *args) const override
Real cleanPriceOAS(Real oas, const Handle< YieldTermStructure > &engineTS, const DayCounter &dayCounter, Compounding compounding, Frequency frequency, Date settlementDate=Date())
Volatility impliedVolatility(const Bond::Price &targetPrice, const Handle< YieldTermStructure > &discountCurve, Real accuracy, Size maxEvaluations, Volatility minVol, Volatility maxVol) const
returns the Black implied forward yield volatility
callable/puttable fixed rate bond
callable/puttable zero coupon bond
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
template base class for option pricing engines
Shared handle to an observable.
Definition: handle.hpp:41
Payment schedule.
Definition: schedule.hpp:40
Frequency
Frequency of events.
Definition: frequency.hpp:37
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Volatility
volatility
Definition: types.hpp:78
Real Spread
spreads on interest rates
Definition: types.hpp:74
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
Compounding
Interest rate coumpounding rule.
Definition: compounding.hpp:32
std::vector< ext::shared_ptr< Callability > > CallabilitySchedule