/src/quantlib/ql/termstructures/volatility/optionlet/constantoptionletvol.hpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2008 Ferdinando Ametrano |
5 | | Copyright (C) 2004, 2005, 2007 StatPro Italia srl |
6 | | Copyright (C) 2015 Peter Caspers |
7 | | |
8 | | This file is part of QuantLib, a free-software/open-source library |
9 | | for financial quantitative analysts and developers - http://quantlib.org/ |
10 | | |
11 | | QuantLib is free software: you can redistribute it and/or modify it |
12 | | under the terms of the QuantLib license. You should have received a |
13 | | copy of the license along with this program; if not, please email |
14 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
15 | | <https://www.quantlib.org/license.shtml>. |
16 | | |
17 | | This program is distributed in the hope that it will be useful, but WITHOUT |
18 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
19 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
20 | | */ |
21 | | |
22 | | /*! \file constantoptionletvol.hpp |
23 | | \brief Constant caplet/floorlet volatility |
24 | | */ |
25 | | |
26 | | #ifndef quantlib_caplet_constant_volatility_hpp |
27 | | #define quantlib_caplet_constant_volatility_hpp |
28 | | |
29 | | #include <ql/termstructures/volatility/optionlet/optionletvolatilitystructure.hpp> |
30 | | |
31 | | namespace QuantLib { |
32 | | |
33 | | class Quote; |
34 | | |
35 | | //! Constant caplet volatility, no time-strike dependence |
36 | | class ConstantOptionletVolatility : public OptionletVolatilityStructure { |
37 | | public: |
38 | | //! floating reference date, floating market data |
39 | | ConstantOptionletVolatility(Natural settlementDays, |
40 | | const Calendar& cal, |
41 | | BusinessDayConvention bdc, |
42 | | Handle<Quote> volatility, |
43 | | const DayCounter& dc, |
44 | | VolatilityType type = ShiftedLognormal, |
45 | | Real displacement = 0.0); |
46 | | //! fixed reference date, floating market data |
47 | | ConstantOptionletVolatility(const Date& referenceDate, |
48 | | const Calendar& cal, |
49 | | BusinessDayConvention bdc, |
50 | | Handle<Quote> volatility, |
51 | | const DayCounter& dc, |
52 | | VolatilityType type = ShiftedLognormal, |
53 | | Real displacement = 0.0); |
54 | | //! floating reference date, fixed market data |
55 | | ConstantOptionletVolatility(Natural settlementDays, const Calendar &cal, |
56 | | BusinessDayConvention bdc, |
57 | | Volatility volatility, const DayCounter &dc, |
58 | | VolatilityType type = ShiftedLognormal, |
59 | | Real displacement = 0.0); |
60 | | //! fixed reference date, fixed market data |
61 | | ConstantOptionletVolatility(const Date &referenceDate, |
62 | | const Calendar &cal, |
63 | | BusinessDayConvention bdc, |
64 | | Volatility volatility, const DayCounter &dc, |
65 | | VolatilityType type = ShiftedLognormal, |
66 | | Real displacement = 0.0); |
67 | | //! \name TermStructure interface |
68 | | //@{ |
69 | | Date maxDate() const override; |
70 | | //@} |
71 | | //! \name VolatilityTermStructure interface |
72 | | //@{ |
73 | | Real minStrike() const override; |
74 | | Real maxStrike() const override; |
75 | | //@} |
76 | | VolatilityType volatilityType() const override; |
77 | | Real displacement() const override; |
78 | | |
79 | | protected: |
80 | | ext::shared_ptr<SmileSection> smileSectionImpl(const Date& d) const override; |
81 | | ext::shared_ptr<SmileSection> smileSectionImpl(Time) const override; |
82 | | Volatility volatilityImpl(Time, Rate) const override; |
83 | | |
84 | | private: |
85 | | Handle<Quote> volatility_; |
86 | | VolatilityType type_; |
87 | | Real displacement_; |
88 | | }; |
89 | | |
90 | | |
91 | | // inline definitions |
92 | | |
93 | 0 | inline Date ConstantOptionletVolatility::maxDate() const { |
94 | 0 | return Date::maxDate(); |
95 | 0 | } |
96 | | |
97 | 0 | inline Real ConstantOptionletVolatility::minStrike() const { |
98 | 0 | return QL_MIN_REAL; |
99 | 0 | } |
100 | | |
101 | 0 | inline Real ConstantOptionletVolatility::maxStrike() const { |
102 | 0 | return QL_MAX_REAL; |
103 | 0 | } |
104 | | |
105 | | inline VolatilityType |
106 | 0 | ConstantOptionletVolatility::volatilityType() const { |
107 | 0 | return type_; |
108 | 0 | } |
109 | | |
110 | 0 | inline Real ConstantOptionletVolatility::displacement() const { |
111 | 0 | return displacement_; |
112 | 0 | } |
113 | | } |
114 | | |
115 | | #endif |