QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
yieldtermstructure.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2004, 2009 Ferdinando Ametrano
5 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
6 Copyright (C) 2003, 2004, 2005, 2006 StatPro Italia srl
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_yield_term_structure_hpp
27#define quantlib_yield_term_structure_hpp
28
29#include <ql/termstructure.hpp>
30#include <ql/interestrate.hpp>
31#include <ql/quote.hpp>
32#include <vector>
33
34namespace QuantLib {
35
37
45 public:
51 explicit YieldTermStructure(const DayCounter& dc = DayCounter());
53 const Calendar& cal = Calendar(),
54 const DayCounter& dc = DayCounter(),
55 std::vector<Handle<Quote> > jumps = {},
56 const std::vector<Date>& jumpDates = {});
58 const Calendar& cal,
59 const DayCounter& dc = DayCounter(),
60 std::vector<Handle<Quote> > jumps = {},
61 const std::vector<Date>& jumpDates = {});
63
72 bool extrapolate = false) const;
77 bool extrapolate = false) const;
79
90 InterestRate zeroRate(const Date& d,
91 const DayCounter& resultDayCounter,
92 Compounding comp,
93 Frequency freq = Annual,
94 bool extrapolate = false) const;
95
101 Compounding comp,
102 Frequency freq = Annual,
103 bool extrapolate = false) const;
105
119 InterestRate forwardRate(const Date& d1,
120 const Date& d2,
121 const DayCounter& resultDayCounter,
122 Compounding comp,
123 Frequency freq = Annual,
124 bool extrapolate = false) const;
130 const Period& p,
131 const DayCounter& resultDayCounter,
132 Compounding comp,
133 Frequency freq = Annual,
134 bool extrapolate = false) const;
135
141 Time t2,
142 Compounding comp,
143 Frequency freq = Annual,
144 bool extrapolate = false) const;
146
148
149 const std::vector<Date>& jumpDates() const;
150 const std::vector<Time>& jumpTimes() const;
152
154
155 void update() override;
157 protected:
167 virtual DiscountFactor discountImpl(Time) const = 0;
169 private:
170 // methods
171 void setJumps(const Date& referenceDate);
172 // data members
173 std::vector<Handle<Quote> > jumps_;
174 std::vector<Date> jumpDates_;
175 std::vector<Time> jumpTimes_;
178 };
179
180 // inline definitions
181
182 inline
184 bool extrapolate) const {
185 return discount(timeFromReference(d), extrapolate);
186 }
187
188 inline
190 const Period& p,
191 const DayCounter& dayCounter,
192 Compounding comp,
193 Frequency freq,
194 bool extrapolate) const {
195 return forwardRate(d, d+p, dayCounter, comp, freq, extrapolate);
196 }
197
198 inline const std::vector<Date>& YieldTermStructure::jumpDates() const {
199 return this->jumpDates_;
200 }
201
202 inline const std::vector<Time>& YieldTermStructure::jumpTimes() const {
203 return this->jumpTimes_;
204 }
205
206}
207
208#endif
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Shared handle to an observable.
Definition: handle.hpp:41
Concrete interest rate class.
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
Time timeFromReference(const Date &date) const
date/time conversion
virtual DayCounter dayCounter() const
the day counter used for date/time conversion
Interest-rate term structure.
DiscountFactor discount(const Date &d, bool extrapolate=false) const
const std::vector< Time > & jumpTimes() const
InterestRate zeroRate(const Date &d, const DayCounter &resultDayCounter, Compounding comp, Frequency freq=Annual, bool extrapolate=false) const
const std::vector< Date > & jumpDates() const
std::vector< Handle< Quote > > jumps_
void setJumps(const Date &referenceDate)
InterestRate forwardRate(const Date &d1, const Date &d2, const DayCounter &resultDayCounter, Compounding comp, Frequency freq=Annual, bool extrapolate=false) const
virtual DiscountFactor discountImpl(Time) const =0
discount factor calculation
Frequency
Frequency of events.
Definition: frequency.hpp:37
@ Annual
once a year
Definition: frequency.hpp:39
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
Real DiscountFactor
discount factor between dates
Definition: types.hpp:66
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
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