/src/quantlib/ql/termstructures/volatility/equityfx/localvoltermstructure.hpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2002, 2003 Ferdinando Ametrano |
5 | | Copyright (C) 2003, 2004, 2005, 2006 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 | | <https://www.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 localvoltermstructure.hpp |
22 | | \brief Local volatility term structure base class |
23 | | */ |
24 | | |
25 | | #ifndef quantlib_local_vol_term_structures_hpp |
26 | | #define quantlib_local_vol_term_structures_hpp |
27 | | |
28 | | #include <ql/termstructures/voltermstructure.hpp> |
29 | | #include <ql/patterns/visitor.hpp> |
30 | | |
31 | | namespace QuantLib { |
32 | | |
33 | | /*! This abstract class defines the interface of concrete |
34 | | local-volatility term structures which will be derived from this one. |
35 | | |
36 | | Volatilities are assumed to be expressed on an annual basis. |
37 | | */ |
38 | | class LocalVolTermStructure : public VolatilityTermStructure { |
39 | | public: |
40 | | /*! \name Constructors |
41 | | See the TermStructure documentation for issues regarding |
42 | | constructors. |
43 | | */ |
44 | | //@{ |
45 | | //! default constructor |
46 | | /*! \warning term structures initialized by means of this |
47 | | constructor must manage their own reference date |
48 | | by overriding the referenceDate() method. |
49 | | */ |
50 | | LocalVolTermStructure(BusinessDayConvention bdc = Following, |
51 | | const DayCounter& dc = DayCounter()); |
52 | | //! initialize with a fixed reference date |
53 | | LocalVolTermStructure(const Date& referenceDate, |
54 | | const Calendar& cal = Calendar(), |
55 | | BusinessDayConvention bdc = Following, |
56 | | const DayCounter& dc = DayCounter()); |
57 | | //! calculate the reference date based on the global evaluation date |
58 | | LocalVolTermStructure(Natural settlementDays, |
59 | | const Calendar&, |
60 | | BusinessDayConvention bdc = Following, |
61 | | const DayCounter& dc = DayCounter()); |
62 | | //@} |
63 | 2.98k | ~LocalVolTermStructure() override = default; |
64 | | //! \name Local Volatility |
65 | | //@{ |
66 | | Volatility localVol(const Date& d, |
67 | | Real underlyingLevel, |
68 | | bool extrapolate = false) const; |
69 | | Volatility localVol(Time t, |
70 | | Real underlyingLevel, |
71 | | bool extrapolate = false) const; |
72 | | //@} |
73 | | //! \name Visitability |
74 | | //@{ |
75 | | virtual void accept(AcyclicVisitor&); |
76 | | //@} |
77 | | protected: |
78 | | /*! \name Calculations |
79 | | |
80 | | These methods must be implemented in derived classes to perform |
81 | | the actual volatility calculations. When they are called, |
82 | | range check has already been performed; therefore, they must |
83 | | assume that extrapolation is required. |
84 | | */ |
85 | | //@{ |
86 | | //! local vol calculation |
87 | | virtual Volatility localVolImpl(Time t, Real strike) const = 0; |
88 | | //@} |
89 | | }; |
90 | | |
91 | | } |
92 | | |
93 | | #endif |