/src/quantlib/ql/termstructures/volatility/swaption/swaptionconstantvol.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) 2006, 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 swaptionconstantvol.hpp |
23 | | \brief Constant swaption volatility |
24 | | */ |
25 | | |
26 | | #ifndef quantlib_swaption_constant_volatility_hpp |
27 | | #define quantlib_swaption_constant_volatility_hpp |
28 | | |
29 | | #include <ql/termstructures/volatility/swaption/swaptionvolstructure.hpp> |
30 | | #include <ql/time/period.hpp> |
31 | | |
32 | | namespace QuantLib { |
33 | | |
34 | | class Quote; |
35 | | |
36 | | //! Constant swaption volatility, no time-strike dependence |
37 | | class ConstantSwaptionVolatility : public SwaptionVolatilityStructure { |
38 | | public: |
39 | | //! floating reference date, floating market data |
40 | | ConstantSwaptionVolatility(Natural settlementDays, |
41 | | const Calendar& cal, |
42 | | BusinessDayConvention bdc, |
43 | | Handle<Quote> volatility, |
44 | | const DayCounter& dc, |
45 | | VolatilityType type = ShiftedLognormal, |
46 | | Real shift = 0.0); |
47 | | //! fixed reference date, floating market data |
48 | | ConstantSwaptionVolatility(const Date& referenceDate, |
49 | | const Calendar& cal, |
50 | | BusinessDayConvention bdc, |
51 | | Handle<Quote> volatility, |
52 | | const DayCounter& dc, |
53 | | VolatilityType type = ShiftedLognormal, |
54 | | Real shift = 0.0); |
55 | | //! floating reference date, fixed market data |
56 | | ConstantSwaptionVolatility(Natural settlementDays, |
57 | | const Calendar& cal, |
58 | | BusinessDayConvention bdc, |
59 | | Volatility volatility, |
60 | | const DayCounter& dc, |
61 | | VolatilityType type = ShiftedLognormal, |
62 | | Real shift = 0.0); |
63 | | //! fixed reference date, fixed market data |
64 | | ConstantSwaptionVolatility(const Date& referenceDate, |
65 | | const Calendar& cal, |
66 | | BusinessDayConvention bdc, |
67 | | Volatility volatility, |
68 | | const DayCounter& dc, |
69 | | VolatilityType type = ShiftedLognormal, |
70 | | Real shift = 0.0); |
71 | | //! \name TermStructure interface |
72 | | //@{ |
73 | | Date maxDate() const override; |
74 | | //@} |
75 | | //! \name VolatilityTermStructure interface |
76 | | //@{ |
77 | | Real minStrike() const override; |
78 | | Real maxStrike() const override; |
79 | | //@} |
80 | | //! \name SwaptionVolatilityStructure interface |
81 | | //@{ |
82 | | const Period& maxSwapTenor() const override; |
83 | | //@} |
84 | | //! volatility type |
85 | | VolatilityType volatilityType() const override; |
86 | | |
87 | | protected: |
88 | | ext::shared_ptr<SmileSection> smileSectionImpl(const Date&, const Period&) const override; |
89 | | ext::shared_ptr<SmileSection> smileSectionImpl(Time, Time) const override; |
90 | | Volatility volatilityImpl(const Date&, const Period&, Rate) const override; |
91 | | Volatility volatilityImpl(Time, Time, Rate) const override; |
92 | | Real shiftImpl(Time optionTime, Time swapLength) const override; |
93 | | |
94 | | private: |
95 | | Handle<Quote> volatility_; |
96 | | Period maxSwapTenor_; |
97 | | VolatilityType volatilityType_; |
98 | | Real shift_; |
99 | | }; |
100 | | |
101 | | |
102 | | // inline definitions |
103 | | |
104 | 0 | inline Date ConstantSwaptionVolatility::maxDate() const { |
105 | 0 | return Date::maxDate(); |
106 | 0 | } |
107 | | |
108 | 0 | inline Real ConstantSwaptionVolatility::minStrike() const { |
109 | 0 | return QL_MIN_REAL; |
110 | 0 | } |
111 | | |
112 | 0 | inline Real ConstantSwaptionVolatility::maxStrike() const { |
113 | 0 | return QL_MAX_REAL; |
114 | 0 | } |
115 | | |
116 | 0 | inline const Period& ConstantSwaptionVolatility::maxSwapTenor() const { |
117 | 0 | return maxSwapTenor_; |
118 | 0 | } |
119 | | |
120 | 0 | inline VolatilityType ConstantSwaptionVolatility::volatilityType() const { |
121 | 0 | return volatilityType_; |
122 | 0 | } |
123 | | |
124 | 0 | inline Real ConstantSwaptionVolatility::shiftImpl(Time optionTime, Time swapLength) const { |
125 | | // consistency check |
126 | 0 | SwaptionVolatilityStructure::shiftImpl(optionTime, swapLength); |
127 | 0 | return shift_; |
128 | 0 | } |
129 | | |
130 | | } |
131 | | |
132 | | #endif |