QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
defaulttermstructure.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 Chris Kenyon
5 Copyright (C) 2008 Roland Lichters
6 Copyright (C) 2008 StatPro Italia srl
7 Copyright (C) 2009 Ferdinando Ametrano
8
9 This file is part of QuantLib, a free-software/open-source library
10 for financial quantitative analysts and developers - http://quantlib.org/
11
12 QuantLib is free software: you can redistribute it and/or modify it
13 under the terms of the QuantLib license. You should have received a
14 copy of the license along with this program; if not, please email
15 <quantlib-dev@lists.sf.net>. The license is also available online at
16 <http://quantlib.org/license.shtml>.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the license for more details.
21*/
22
27#ifndef quantlib_default_term_structure_hpp
28#define quantlib_default_term_structure_hpp
29
30#include <ql/termstructure.hpp>
31#include <ql/quote.hpp>
32
33namespace QuantLib {
34
36
42 public:
49 const DayCounter& dc = DayCounter(),
50 std::vector<Handle<Quote> > jumps = {},
51 const std::vector<Date>& jumpDates = {});
53 const Date& referenceDate,
54 const Calendar& cal = Calendar(),
55 const DayCounter& dc = DayCounter(),
56 std::vector<Handle<Quote> > jumps = {},
57 const std::vector<Date>& jumpDates = {});
60 const Calendar& cal,
61 const DayCounter& dc = DayCounter(),
62 std::vector<Handle<Quote> > jumps = {},
63 const std::vector<Date>& jumpDates = {});
65
74 bool extrapolate = false) const;
79 bool extrapolate = false) const;
81
90 bool extrapolate = false) const;
95 bool extrapolate = false) const;
98 const Date&,
99 bool extrapolate = false) const;
102 Time,
103 bool extrapo = false) const;
105
113 Real defaultDensity(const Date& d,
114 bool extrapolate = false) const;
116 bool extrapolate = false) const;
118
131 bool extrapolate = false) const;
133 bool extrapolate = false) const;
135
137
138 const std::vector<Date>& jumpDates() const;
139 const std::vector<Time>& jumpTimes() const;
141
143
144 void update() override;
146 protected:
160 virtual Real defaultDensityImpl(Time) const = 0;
162 virtual Real hazardRateImpl(Time) const;
164 private:
165 // methods
166 void setJumps();
167 // data members
168 std::vector<Handle<Quote> > jumps_;
169 std::vector<Date> jumpDates_;
170 std::vector<Time> jumpTimes_;
173 };
174
175 // inline definitions
176
177 inline
179 const Date& d,
180 bool extrapolate) const {
181 return survivalProbability(timeFromReference(d), extrapolate);
182 }
183
184 inline
186 const Date& d,
187 bool extrapolate) const {
188 return 1.0 - survivalProbability(d, extrapolate);
189 }
190
191 inline
193 Time t,
194 bool extrapolate) const {
195 return 1.0 - survivalProbability(t, extrapolate);
196 }
197
198 inline
200 const Date& d,
201 bool extrapolate) const {
202 return defaultDensity(timeFromReference(d), extrapolate);
203 }
204
205 inline
207 Time t,
208 bool extrapolate) const {
209 checkRange(t, extrapolate);
210 return defaultDensityImpl(t);
211 }
212
213 inline
215 bool extrapolate) const {
216 return hazardRate(timeFromReference(d), extrapolate);
217 }
218
219 inline
222 return S == 0.0 ? Rate(0.0) : defaultDensity(t, true)/S;
223 }
224
226 bool extrapolate) const {
227 checkRange(t, extrapolate);
228 return hazardRateImpl(t);
229 }
230
231 inline
232 const std::vector<Date>&
234 return this->jumpDates_;
235 }
236
237 inline
238 const std::vector<Time>&
240 return this->jumpTimes_;
241 }
242
246 setJumps();
247 }
248
249}
250
251#endif
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Default probability term structure.
Probability survivalProbability(const Date &d, bool extrapolate=false) const
virtual Probability survivalProbabilityImpl(Time) const =0
survival probability calculation
virtual Real defaultDensityImpl(Time) const =0
default density calculation
Probability defaultProbability(const Date &d, bool extrapolate=false) const
const std::vector< Time > & jumpTimes() const
Rate hazardRate(const Date &d, bool extrapolate=false) const
Real defaultDensity(const Date &d, bool extrapolate=false) const
const std::vector< Date > & jumpDates() const
virtual Real hazardRateImpl(Time) const
hazard rate calculation
Shared handle to an observable.
Definition: handle.hpp:41
Basic term-structure functionality.
virtual Natural settlementDays() const
the settlementDays used for reference date calculation
virtual const Date & referenceDate() const
the date at which discount = 1.0 and/or variance = 0.0
void update() override
Time timeFromReference(const Date &date) const
date/time conversion
void checkRange(const Date &d, bool extrapolate) const
date-range check
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Probability
probability
Definition: types.hpp:82
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35