QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
forwardspreadedtermstructure.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
5 Copyright (C) 2003, 2004, 2008 StatPro Italia srl
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
25#ifndef quantlib_forward_spreaded_term_structure_hpp
26#define quantlib_forward_spreaded_term_structure_hpp
27
28#include <ql/quote.hpp>
29#include <ql/termstructures/yield/forwardstructure.hpp>
30#include <utility>
31
32namespace QuantLib {
33
35
48 public:
51
52 DayCounter dayCounter() const override;
53 Date maxDate() const override;
54 Time maxTime() const override;
55 const Date& referenceDate() const override;
56 Calendar calendar() const override;
57 Natural settlementDays() const override;
59
61 void update() override;
63 protected:
65
66 Rate forwardImpl(Time t) const override;
67 /* This method must disappear should the spread become a curve */
68 Rate zeroYieldImpl(Time t) const override;
70 private:
73 };
74
76 Handle<Quote> spread)
77 : originalCurve_(std::move(h)), spread_(std::move(spread)) {
80 }
81
83 return originalCurve_->dayCounter();
84 }
85
87 return originalCurve_->calendar();
88 }
89
91 return originalCurve_->settlementDays();
92 }
93
95 return originalCurve_->referenceDate();
96 }
97
99 return originalCurve_->maxDate();
100 }
101
103 return originalCurve_->maxTime();
104 }
105
107 if (!originalCurve_.empty()) {
109 } else {
110 /* The implementation inherited from YieldTermStructure
111 asks for our reference date, which we don't have since
112 the original curve is still not set. Therefore, we skip
113 over that and just call the base-class behavior. */
114 // NOLINTNEXTLINE(bugprone-parent-virtual-call)
116 }
117 }
118
120 return originalCurve_->forwardRate(t, t, Continuous, NoFrequency, true)
121 + spread_->value();
122 }
123
125 return originalCurve_->zeroRate(t, Continuous, NoFrequency, true)
126 + spread_->value();
127 }
128
129}
130
131#endif
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Forward-rate term structure
Term structure with added spread on the instantaneous forward rate.
Calendar calendar() const override
the calendar used for reference and/or option date calculation
Rate forwardImpl(Time t) const override
instantaneous forward-rate calculation
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
ForwardSpreadedTermStructure(Handle< YieldTermStructure >, Handle< Quote > spread)
Time maxTime() const override
the latest time for which the curve can return values
Shared handle to an observable.
Definition: handle.hpp:41
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
void update() override
@ NoFrequency
null frequency
Definition: frequency.hpp:37
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35
STL namespace.