QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
termstructure.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2004, 2005, 2006, 2007 StatPro Italia srl
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
24#ifndef quantlib_term_structure_hpp
25#define quantlib_term_structure_hpp
26
27#include <ql/time/calendar.hpp>
28#include <ql/time/daycounter.hpp>
29#include <ql/settings.hpp>
30#include <ql/handle.hpp>
31#include <ql/math/interpolations/extrapolation.hpp>
32#include <ql/utilities/null.hpp>
33
34namespace QuantLib {
35
37 class TermStructure : public virtual Observer,
38 public virtual Observable,
39 public Extrapolator {
40 public:
63
67 explicit TermStructure(DayCounter dc = DayCounter());
69 explicit TermStructure(const Date& referenceDate,
71 DayCounter dc = DayCounter());
75 ~TermStructure() override = default;
77
78
79 virtual DayCounter dayCounter() const;
81 Time timeFromReference(const Date& date) const;
83 virtual Date maxDate() const = 0;
85 virtual Time maxTime() const;
87 virtual const Date& referenceDate() const;
89 virtual Calendar calendar() const;
91 virtual Natural settlementDays() const;
93
95 void update() override;
97 protected:
99 void checkRange(const Date& d,
100 bool extrapolate) const;
102 void checkRange(Time t,
103 bool extrapolate) const;
104 bool moving_ = false;
105 mutable bool updated_ = true;
107 private:
111 };
112
113 // inline definitions
114
116 return dayCounter_;
117 }
118
120 return timeFromReference(maxDate());
121 }
122
124 return calendar_;
125 }
126
128 QL_REQUIRE(settlementDays_!=Null<Natural>(),
129 "settlement days not provided for this instance");
130 return settlementDays_;
131 }
132
135 }
136
137}
138
139#endif
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Time yearFraction(const Date &, const Date &, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date()) const
Returns the period between two dates as a fraction of year.
Definition: daycounter.hpp:128
base class for classes possibly allowing extrapolation
template class providing a null value for a given type.
Definition: null.hpp:76
Object that notifies its changes to a set of observers.
Definition: observable.hpp:62
Object that gets notified when a given observable changes.
Definition: observable.hpp:116
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
virtual Calendar calendar() const
the calendar used for reference and/or option date calculation
void update() override
virtual Time maxTime() const
the latest time for which the curve can return values
~TermStructure() override=default
virtual Date maxDate() const =0
the latest date for which the curve can return values
Time timeFromReference(const Date &date) const
date/time conversion
void checkRange(const Date &d, bool extrapolate) const
date-range check
virtual DayCounter dayCounter() const
the day counter used for date/time conversion
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Definition: any.hpp:35