QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
impliedtermstructure.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) 2000, 2001, 2002, 2003 RiskMap srl
5 Copyright (C) 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
21/*! \file impliedtermstructure.hpp
22 \brief Implied term structure
23*/
24
25#ifndef quantlib_implied_term_structure_hpp
26#define quantlib_implied_term_structure_hpp
27
29#include <utility>
30
31namespace QuantLib {
32
33 //! Implied term structure at a given date in the future
34 /*! The given date will be the implied reference date.
35
36 \note This term structure will remain linked to the original
37 structure, i.e., any changes in the latter will be
38 reflected in this structure as well.
39
40 \ingroup yieldtermstructures
41
42 \test
43 - the correctness of the returned values is tested by
44 checking them against numerical calculations.
45 - observability against changes in the underlying term
46 structure is checked.
47 */
49 public:
51 //! \name YieldTermStructure interface
52 //@{
53 DayCounter dayCounter() const override;
54 Calendar calendar() const override;
55 Natural settlementDays() const override;
56 Date maxDate() const override;
57
58 protected:
59 DiscountFactor discountImpl(Time) const override;
60 //@}
61 private:
63 };
64
65
66 // inline definitions
67
69 const Date& referenceDate)
70 : YieldTermStructure(referenceDate), originalCurve_(std::move(h)) {
72 }
73
75 return originalCurve_->dayCounter();
76 }
77
79 return originalCurve_->calendar();
80 }
81
83 return originalCurve_->settlementDays();
84 }
85
87 return originalCurve_->maxDate();
88 }
89
91 /* t is relative to the current reference date
92 and needs to be converted to the time relative
93 to the reference date of the original curve */
94 Date ref = referenceDate();
95 Time originalTime = t + dayCounter().yearFraction(
96 originalCurve_->referenceDate(), ref);
97 /* discount at evaluation date cannot be cached
98 since the original curve could change between
99 invocations of this method */
100 return originalCurve_->discount(originalTime, true) /
101 originalCurve_->discount(ref, true);
102 }
103
104}
105
106
107#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
Shared handle to an observable.
Definition: handle.hpp:41
Implied term structure at a given date in the future.
Calendar calendar() const override
the calendar used for reference and/or option date calculation
ImpliedTermStructure(Handle< YieldTermStructure >, const Date &referenceDate)
Handle< YieldTermStructure > originalCurve_
Natural settlementDays() const override
the settlementDays used for reference date calculation
DayCounter dayCounter() const override
the day counter used for date/time conversion
DiscountFactor discountImpl(Time) const override
discount factor calculation
Date maxDate() const override
the latest date for which the curve can return values
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
virtual const Date & referenceDate() const
the date at which discount = 1.0 and/or variance = 0.0
Interest-rate term structure.
const DefaultType & t
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
Definition: any.hpp:35
STL namespace.
Interest-rate term structure.