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
29namespace 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 VolatilityTermStructure::businessDayConvention() const {
80 return bdc_;
81 }
82
83 inline Date
84 VolatilityTermStructure::optionDateFromTenor(const Period& p) const {
85 // swaption style
86 return calendar().advance(date: referenceDate(),
87 period: p,
88 convention: businessDayConvention());
89 }
90}
91
92#endif
93

source code of quantlib/ql/termstructures/voltermstructure.hpp