QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
blackvolsurface.hpp
Go to the documentation of this file.
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 <http://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 blackvolsurface.hpp
22 \brief Black volatility (smile) surface
23*/
24
25#ifndef quantlib_black_vol_surface_hpp
26#define quantlib_black_vol_surface_hpp
27
29
30namespace QuantLib {
31
32 class SmileSection;
33
34 //! Black volatility (smile) surface
35 /*! This abstract class defines the interface of concrete
36 Black volatility (smile) surface which will
37 be derived from this one.
38
39 Volatilities are assumed to be expressed on an annual basis.
40
41 */
43 public:
44 /*! \name Constructors
45 See the TermStructure documentation for issues regarding
46 constructors.
47 */
48 //@{
49 //! default constructor
50 /*! \warning term structures initialized by means of this
51 constructor must manage their own reference date
52 by overriding the referenceDate() method.
53 */
55 const DayCounter& dc = DayCounter());
56 //! initialize with a fixed reference date
58 const Calendar& cal = Calendar(),
60 const DayCounter& dc = DayCounter());
61 //! calculate the reference date based on the global evaluation date
63 const Calendar&,
65 const DayCounter& dc = DayCounter());
66 //@}
67 //! \name Black spot volatility
68 //@{
69 //! returns the smile for a given option tenor
70 ext::shared_ptr<SmileSection> smileSection(const Period&,
71 bool extrapolate) const;
72 //! returns the smile for a given option date
73 ext::shared_ptr<SmileSection> smileSection(const Date&,
74 bool extrapolate) const;
75 //! returns the smile for a given option time
76 ext::shared_ptr<SmileSection> smileSection(Time,
77 bool extrapolate) const;
78 //@}
79 //! \name Visitability
80 //@{
81 void accept(AcyclicVisitor&) override;
82 //@}
83 protected:
84 //! \name BlackAtmVolCurve interface
85 //@{
86 //! spot at-the-money variance calculation
87 Real atmVarianceImpl(Time t) const override;
88 //! spot at-the-money volatility calculation
89 Volatility atmVolImpl(Time t) const override;
90 //@}
91 /*! \name Calculations
92
93 This method must be implemented in derived classes to perform
94 the actual volatility calculations. When it is called,
95 time check has already been performed; therefore, it must
96 assume that time-extrapolation is allowed.
97 */
98 //@{
99 virtual ext::shared_ptr<SmileSection> smileSectionImpl(Time) const=0;
100 //@}
101 };
102
103 // inline definitions
104
105 inline ext::shared_ptr<SmileSection>
107 bool extrapolate) const {
108 return smileSection(optionDateFromTenor(p), extrapolate);
109 }
110
111 inline ext::shared_ptr<SmileSection>
113 bool extrapolate) const {
114 return smileSection(timeFromReference(d), extrapolate);
115 }
116
117 inline ext::shared_ptr<SmileSection>
119 bool extrapolate) const {
120 checkRange(t, extrapolate);
121 return smileSectionImpl(t);
122 }
123
124}
125
126#endif
Black at-the-money (no-smile) volatility curve base class.
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Black at-the-money (no-smile) volatility curve.
Black volatility (smile) surface.
virtual ext::shared_ptr< SmileSection > smileSectionImpl(Time) const =0
Volatility atmVolImpl(Time t) const override
spot at-the-money volatility calculation
void accept(AcyclicVisitor &) override
Real atmVarianceImpl(Time t) const override
spot at-the-money variance calculation
ext::shared_ptr< SmileSection > smileSection(const Period &, bool extrapolate) const
returns the smile for a given option tenor
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
virtual Natural settlementDays() const
the settlementDays used for reference date calculation
virtual const Date & referenceDate() const
the date at which discount = 1.0 and/or variance = 0.0
Time timeFromReference(const Date &date) const
date/time conversion
void checkRange(const Date &d, bool extrapolate) const
date-range check
Date optionDateFromTenor(const Period &) const
period/date conversion
const DefaultType & t
Date d
BusinessDayConvention
Business Day conventions.
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Volatility
volatility
Definition: types.hpp:78
Definition: any.hpp:35