QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
blackvolsurface.hpp
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
25#ifndef quantlib_black_vol_surface_hpp
26#define quantlib_black_vol_surface_hpp
27
28#include <ql/experimental/volatility/blackatmvolcurve.hpp>
29
30namespace QuantLib {
31
32 class SmileSection;
33
35
43 public:
50
55 const DayCounter& dc = DayCounter());
58 const Calendar& cal = Calendar(),
60 const DayCounter& dc = DayCounter());
63 const Calendar&,
65 const DayCounter& dc = DayCounter());
67
69
70 ext::shared_ptr<SmileSection> smileSection(const Period&,
71 bool extrapolate) const;
73 ext::shared_ptr<SmileSection> smileSection(const Date&,
74 bool extrapolate) const;
76 ext::shared_ptr<SmileSection> smileSection(Time,
77 bool extrapolate) const;
79
81 void accept(AcyclicVisitor&) override;
83 protected:
85
86
87 Real atmVarianceImpl(Time t) const override;
89 Volatility atmVolImpl(Time t) const override;
91
99 virtual ext::shared_ptr<SmileSection> smileSectionImpl(Time) const=0;
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
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
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