QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
localvoltermstructure.cpp
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
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
21
22namespace QuantLib {
23
25 const DayCounter& dc)
26 : VolatilityTermStructure(bdc, dc) {}
27
29 const Calendar& cal,
31 const DayCounter& dc)
32 : VolatilityTermStructure(referenceDate, cal, bdc, dc) {}
33
35 const Calendar& cal,
37 const DayCounter& dc)
38 : VolatilityTermStructure(settlementDays, cal, bdc, dc) {}
39
41 Real underlyingLevel,
42 bool extrapolate) const {
43 checkRange(d, extrapolate);
44 checkStrike(underlyingLevel, extrapolate);
46 return localVolImpl(t, underlyingLevel);
47 }
48
50 Real underlyingLevel,
51 bool extrapolate) const {
52 checkRange(t, extrapolate);
53 checkStrike(underlyingLevel, extrapolate);
54 return localVolImpl(t, underlyingLevel);
55 }
56
58 auto* v1 = dynamic_cast<Visitor<LocalVolTermStructure>*>(&v);
59 if (v1 != nullptr)
60 v1->visit(*this);
61 else
62 QL_FAIL("not a local-volatility term structure visitor");
63 }
64
65}
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
virtual Volatility localVolImpl(Time t, Real strike) const =0
local vol calculation
virtual void accept(AcyclicVisitor &)
LocalVolTermStructure(BusinessDayConvention bdc=Following, const DayCounter &dc=DayCounter())
default constructor
Volatility localVol(const Date &d, Real underlyingLevel, bool extrapolate=false) const
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.
void checkStrike(Rate strike, bool extrapolate) const
strike-range check
const DefaultType & t
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Definition: errors.hpp:92
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
Local volatility term structure base class.
Definition: any.hpp:35
ext::shared_ptr< BlackVolTermStructure > v