/src/quantlib/ql/termstructures/voltermstructure.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2007 Ferdinando Ametrano |
5 | | |
6 | | This file is part of QuantLib, a free-software/open-source library |
7 | | for financial quantitative analysts and developers - http://quantlib.org/ |
8 | | |
9 | | QuantLib is free software: you can redistribute it and/or modify it |
10 | | under the terms of the QuantLib license. You should have received a |
11 | | copy of the license along with this program; if not, please email |
12 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
13 | | <http://quantlib.org/license.shtml>. |
14 | | |
15 | | This program is distributed in the hope that it will be useful, but WITHOUT |
16 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
17 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
18 | | */ |
19 | | |
20 | | /*! \file voltermstructure.hpp |
21 | | \brief Volatility term structure |
22 | | */ |
23 | | |
24 | | #ifndef quantlib_vol_term_structure_hpp |
25 | | #define quantlib_vol_term_structure_hpp |
26 | | |
27 | | #include <ql/termstructure.hpp> |
28 | | |
29 | | namespace QuantLib { |
30 | | |
31 | | //! Volatility term structure |
32 | | /*! This abstract class defines the interface of concrete |
33 | | volatility structures which will be derived from this one. |
34 | | |
35 | | */ |
36 | | class VolatilityTermStructure : public TermStructure { |
37 | | public: |
38 | | /*! \name Constructors |
39 | | See the TermStructure documentation for issues regarding |
40 | | constructors. |
41 | | */ |
42 | | //@{ |
43 | | /*! \warning term structures initialized by means of this |
44 | | constructor must manage their own reference date |
45 | | by overriding the referenceDate() method. |
46 | | */ |
47 | | VolatilityTermStructure(BusinessDayConvention bdc, |
48 | | const DayCounter& dc = DayCounter()); |
49 | | //! initialize with a fixed reference date |
50 | | VolatilityTermStructure(const Date& referenceDate, |
51 | | const Calendar& cal, |
52 | | BusinessDayConvention bdc, |
53 | | const DayCounter& dc = DayCounter()); |
54 | | //! calculate the reference date based on the global evaluation date |
55 | | VolatilityTermStructure(Natural settlementDays, |
56 | | const Calendar& cal, |
57 | | BusinessDayConvention bdc, |
58 | | const DayCounter& dc = DayCounter()); |
59 | | //@} |
60 | | //! the business day convention used in tenor to date conversion |
61 | | virtual BusinessDayConvention businessDayConvention() const; |
62 | | //! period/date conversion |
63 | | Date optionDateFromTenor(const Period&) const; |
64 | | //! the minimum strike for which the term structure can return vols |
65 | | virtual Rate minStrike() const = 0; |
66 | | //! the maximum strike for which the term structure can return vols |
67 | | virtual Rate maxStrike() const = 0; |
68 | | protected: |
69 | | //! strike-range check |
70 | | void checkStrike(Rate strike, |
71 | | bool extrapolate) const; |
72 | | private: |
73 | | BusinessDayConvention bdc_; |
74 | | }; |
75 | | |
76 | | // inline definitions |
77 | | |
78 | | inline BusinessDayConvention |
79 | 0 | VolatilityTermStructure::businessDayConvention() const { |
80 | 0 | return bdc_; |
81 | 0 | } |
82 | | |
83 | | inline Date |
84 | 0 | VolatilityTermStructure::optionDateFromTenor(const Period& p) const { |
85 | 0 | // swaption style |
86 | 0 | return calendar().advance(referenceDate(), |
87 | 0 | p, |
88 | 0 | businessDayConvention()); |
89 | 0 | } |
90 | | } |
91 | | |
92 | | #endif |