QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
termstructure.cpp
Go to the documentation of this file.
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
21#include <ql/termstructure.hpp>
22#include <utility>
23
24namespace QuantLib {
25
27 : settlementDays_(Null<Natural>()), dayCounter_(std::move(dc)) {}
28
30 : calendar_(std::move(cal)), referenceDate_(referenceDate), settlementDays_(Null<Natural>()),
31 dayCounter_(std::move(dc)) {}
32
34 : moving_(true), updated_(false), calendar_(std::move(cal)), settlementDays_(settlementDays),
35 dayCounter_(std::move(dc)) {
36 registerWith(Settings::instance().evaluationDate());
37 }
38
40 if (!updated_) {
43 updated_ = true;
44 }
45 return referenceDate_;
46 }
47
49 if (moving_)
50 updated_ = false;
52 }
53
55 bool extrapolate) const {
57 "date (" << d << ") before reference date (" <<
58 referenceDate() << ")");
59 QL_REQUIRE(extrapolate || allowsExtrapolation() || d <= maxDate(),
60 "date (" << d << ") is past max curve date ("
61 << maxDate() << ")");
62 }
63
65 bool extrapolate) const {
66 QL_REQUIRE(t >= 0.0,
67 "negative time (" << t << ") given");
68 QL_REQUIRE(extrapolate || allowsExtrapolation()
69 || t <= maxTime() || close_enough(t, maxTime()),
70 "time (" << t << ") is past max curve time ("
71 << maxTime() << ")");
72 }
73
74}
calendar class
Definition: calendar.hpp:61
Date advance(const Date &, Integer n, TimeUnit unit, BusinessDayConvention convention=Following, bool endOfMonth=false) const
Definition: calendar.cpp:130
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
bool allowsExtrapolation() const
tells whether extrapolation is enabled
template class providing a null value for a given type.
Definition: null.hpp:76
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
DateProxy & evaluationDate()
the date at which pricing is to be performed.
Definition: settings.hpp:147
static Settings & instance()
access to the unique instance
Definition: singleton.hpp:104
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(DayCounter dc=DayCounter())
default constructor
virtual Date maxDate() const =0
the latest date for which the curve can return values
void checkRange(const Date &d, bool extrapolate) const
date-range check
floating-point comparisons
const DefaultType & t
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
Date d
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
bool close_enough(const Quantity &m1, const Quantity &m2, Size n)
Definition: quantity.cpp:182
STL namespace.
base class for term structures