QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ultimateforwardtermstructure.hpp
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) 2020 Marcin Rybacki
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
20/*! \file ultimateforwardtermstructure.hpp
21 \brief Ultimate Forward Rate term structure
22*/
23
24#ifndef quantlib_ultimate_forward_term_structure_hpp
25#define quantlib_ultimate_forward_term_structure_hpp
26
27#include <ql/quote.hpp>
29#include <utility>
30
31namespace QuantLib {
32
33 //! Ultimate forward term structure
34
35 /*! Dutch regulatory term structure for pension funds with a
36 parametrized extrapolation mechanism designed for
37 discounting long dated liabilities.
38
39 Relevant documentation can be found on the Dutch Central
40 Bank website:
41
42 FTK term structure documentation (Financieel toetsingskader):
43 https://www.toezicht.dnb.nl/binaries/50-212329.pdf
44
45 UFR 2015 term structure documentation:
46 https://www.toezicht.dnb.nl/binaries/50-234028.pdf
47
48 UFR 2019 term structure documentation:
49 https://www.rijksoverheid.nl/documenten/kamerstukken/2019/06/11/advies-commissie-parameters
50
51 This term structure will remain linked to the original
52 structure, i.e., any changes in the latter will be
53 reflected in this structure as well.
54
55 \ingroup yieldtermstructures
56
57 \test
58 - the correctness of the returned zero rates is tested by
59 checking them against reference values obtained
60 from the official source.
61 - extrapolated forward is validated.
62 - rates on the cut-off point are checked against those
63 implied by the base curve.
64 - inspectors are tested against the base curve.
65 - incorrect input for cut-off point should raise an exception.
66 - observability against changes in the underlying term
67 structure and the additional components is checked.
68 */
69
71 public:
73 Handle<Quote> lastLiquidForwardRate,
74 Handle<Quote> ultimateForwardRate,
75 const Period& firstSmoothingPoint,
76 Real alpha);
77 //! \name YieldTermStructure interface
78 //@{
79 DayCounter dayCounter() const override;
80 Calendar calendar() const override;
81 Natural settlementDays() const override;
82 const Date& referenceDate() const override;
83 Date maxDate() const override;
84 //@}
85 //! \name Observer interface
86 //@{
87 void update() override;
88 //@}
89 protected:
90 //! returns the UFR extended zero yield rate
91 Rate zeroYieldImpl(Time) const override;
92 //@}
93 private:
99 };
100
101 // inline definitions
102
105 Handle<Quote> lastLiquidForwardRate,
106 Handle<Quote> ultimateForwardRate,
107 const Period& firstSmoothingPoint,
108 Real alpha)
109 : originalCurve_(std::move(h)), llfr_(std::move(lastLiquidForwardRate)),
110 ufr_(std::move(ultimateForwardRate)), fsp_(firstSmoothingPoint), alpha_(alpha) {
111 QL_REQUIRE(fsp_.length() > 0,
112 "first smoothing point must be a period with positive length");
113 if (!originalCurve_.empty())
114 enableExtrapolation(originalCurve_->allowsExtrapolation());
118 }
119
121 return originalCurve_->dayCounter();
122 }
123
125 return originalCurve_->calendar();
126 }
127
129 return originalCurve_->settlementDays();
130 }
131
133 return originalCurve_->referenceDate();
134 }
135
137
139 if (!originalCurve_.empty()) {
141 enableExtrapolation(originalCurve_->allowsExtrapolation());
142 } else {
143 /* The implementation inherited from YieldTermStructure
144 asks for our reference date, which we don't have since
145 the original curve is still not set. Therefore, we skip
146 over that and just call the base-class behavior. */
147 // NOLINTNEXTLINE(bugprone-parent-virtual-call)
149 }
150 }
151
153 Time cutOffTime = originalCurve_->timeFromReference(referenceDate() + fsp_);
154 Time deltaT = t - cutOffTime;
155 /* If time to maturity (T) exceeds the cut-off point (T_c),
156 i.e. the first smoothing point, the forward rate f is
157 extrapolated as follows:
158
159 f(t,T_c,T) = UFR(t) + (LLFR(t) - UFR(t)) * B(T-T_c),
160
161 where:
162 UFR(t) - Ultimate Forward Rate quote,
163 LLFR(t) - Last Liquid Forward Rate quote,
164 B(t-T_c) = [1 - exp(-a * (T-T_c))] / [a * (T-T_c)],
165 with a being the growth factor (alpha). */
166 if (deltaT > 0.0) {
167 InterestRate baseRate = originalCurve_->zeroRate(cutOffTime, Continuous, NoFrequency);
168 Real beta = (1.0 - std::exp(-alpha_ * deltaT)) / (alpha_ * deltaT);
169 Rate extrapolatedForward = ufr_->value() + (llfr_->value() - ufr_->value()) * beta;
170 return (cutOffTime * baseRate + deltaT * extrapolatedForward) / t;
171 }
172 return originalCurve_->zeroRate(t, Continuous, NoFrequency);
173 }
174}
175
176#endif
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
static Date maxDate()
latest allowed date
Definition: date.cpp:771
day counter class
Definition: daycounter.hpp:44
void enableExtrapolation(bool b=true)
enable extrapolation in subsequent calls
Shared handle to an observable.
Definition: handle.hpp:41
Concrete interest rate class.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
Integer length() const
Definition: period.hpp:50
void update() override
Calendar calendar() const override
the calendar used for reference and/or option date calculation
Rate zeroYieldImpl(Time) const override
returns the UFR extended zero yield rate
const Date & referenceDate() const override
the date at which discount = 1.0 and/or variance = 0.0
Natural settlementDays() const override
the settlementDays used for reference date calculation
DayCounter dayCounter() const override
the day counter used for date/time conversion
Date maxDate() const override
the latest date for which the curve can return values
UltimateForwardTermStructure(Handle< YieldTermStructure >, Handle< Quote > lastLiquidForwardRate, Handle< Quote > ultimateForwardRate, const Period &firstSmoothingPoint, Real alpha)
Zero-yield term structure.
const DefaultType & t
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
@ NoFrequency
null frequency
Definition: frequency.hpp:37
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 Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35
STL namespace.
purely virtual base class for market observables
Real beta
Definition: sabr.cpp:200
Real alpha
Definition: sabr.cpp:200
Zero-yield based term structure.