QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
impliedtermstructure.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) 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_implied_term_structure_hpp
26#define quantlib_implied_term_structure_hpp
27
28#include <ql/termstructures/yieldtermstructure.hpp>
29#include <utility>
30
31namespace QuantLib {
32
34
49 public:
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;
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.
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.