QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
blackatmvolcurve.cpp
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#include <ql/experimental/volatility/blackatmvolcurve.hpp>
21
22namespace QuantLib {
23
25 const DayCounter& dc)
26 : VolatilityTermStructure(bdc, dc) {}
27
29 const Calendar& cal,
31 const DayCounter& dc)
32 : VolatilityTermStructure(refDate, cal, bdc, dc) {}
33
35 const Calendar& cal,
37 const DayCounter& dc)
38 : VolatilityTermStructure(settlDays, cal, bdc, dc) {}
39
41 bool extrapolate) const {
42 Date d = optionDateFromTenor(optionTenor);
43 return atmVol(d, extrapolate);
44 }
45
47 bool extrapolate) const {
49 return atmVol(t, extrapolate);
50 }
51
53 bool extrapolate) const {
54 checkRange(t, extrapolate);
55 return atmVolImpl(t);
56 }
57
59 bool extrapolate) const {
60 Date d = optionDateFromTenor(optionTenor);
61 return atmVariance(d, extrapolate);
62 }
63
65 bool extrapolate) const {
67 return atmVariance(t, extrapolate);
68 }
69
71 bool extrapolate) const {
72 checkRange(t, extrapolate);
73 return atmVarianceImpl(t);
74 }
75
77 auto* v1 = dynamic_cast<Visitor<BlackAtmVolCurve>*>(&v);
78 if (v1 != nullptr)
79 v1->visit(*this);
80 else
81 QL_FAIL("not a BlackAtmVolCurve visitor");
82 }
83
84}
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Volatility atmVol(const Period &optionTenor, bool extrapolate=false) const
spot at-the-money volatility
virtual void accept(AcyclicVisitor &)
virtual Volatility atmVolImpl(Time t) const =0
spot at-the-money volatility calculation
virtual Real atmVarianceImpl(Time t) const =0
spot at-the-money variance calculation
Real atmVariance(const Period &optionTenor, bool extrapolate=false) const
spot at-the-money variance
BlackAtmVolCurve(BusinessDayConvention bdc=Following, const DayCounter &dc=DayCounter())
default constructor
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Time timeFromReference(const Date &date) const
date/time conversion
void checkRange(const Date &d, bool extrapolate) const
date-range check
Visitor for a specific class
Definition: visitor.hpp:40
virtual void visit(T &)=0
Volatility term structure.
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