QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
blackvolsurface.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/blackvolsurface.hpp>
21#include <ql/termstructures/volatility/smilesection.hpp>
22
23namespace QuantLib {
24
26 const DayCounter& dc)
27 : BlackAtmVolCurve(bdc, dc) {}
28
30 const Calendar& cal,
32 const DayCounter& dc)
33 : BlackAtmVolCurve(refDate, cal, bdc, dc) {}
34
36 const Calendar& cal,
38 const DayCounter& dc)
39 : BlackAtmVolCurve(settlDays, cal, bdc, dc) {}
40
42 const ext::shared_ptr<SmileSection>& s = smileSectionImpl(t);
43 return s->variance(s->atmLevel());
44 }
45
47 const ext::shared_ptr<SmileSection>& s = smileSectionImpl(t);
48 return s->volatility(s->atmLevel());
49 }
50
52 auto* v1 = dynamic_cast<Visitor<BlackVolSurface>*>(&v);
53 if (v1 != nullptr)
54 v1->visit(*this);
55 else
56 QL_FAIL("not a BlackVolSurface term structure visitor");
57 }
58
59}
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Black at-the-money (no-smile) volatility curve.
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
BlackVolSurface(BusinessDayConvention bdc=Following, const DayCounter &dc=DayCounter())
default constructor
Real atmVarianceImpl(Time t) const override
spot at-the-money variance calculation
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Visitor for a specific class
Definition: visitor.hpp:40
virtual void visit(T &)=0
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