QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
noexceptlocalvolsurface.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) 2015 Klaus Spanderen
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/*! \file noexceptlocalvolsurface.hpp
21 \brief wrapper around Dupire local volatility surface,
22 which does not throw exception if local volatility becomes negative
23*/
24
25#ifndef quantlib_no_except_localvolsurface_hpp
26#define quantlib_no_except_localvolsurface_hpp
27
29
30namespace QuantLib {
31
33 public:
35 const Handle<YieldTermStructure>& riskFreeTS,
36 const Handle<YieldTermStructure>& dividendTS,
37 const Handle<Quote>& underlying,
38 Real illegalLocalVolOverwrite)
39 : LocalVolSurface(blackTS, riskFreeTS, dividendTS, underlying),
40 illegalLocalVolOverwrite_(illegalLocalVolOverwrite) { }
41
43 const Handle<YieldTermStructure>& riskFreeTS,
44 const Handle<YieldTermStructure>& dividendTS,
45 Real underlying,
46 Real illegalLocalVolOverwrite)
47 : LocalVolSurface(blackTS, riskFreeTS, dividendTS, underlying),
48 illegalLocalVolOverwrite_(illegalLocalVolOverwrite) { }
49
50 protected:
51 Volatility localVolImpl(Time t, Real s) const override {
52 Volatility vol;
53 try {
55 } catch (Error&) {
57 }
58
59 return vol;
60 }
61
62 private:
64 };
65}
66
67#endif
Base error class.
Definition: errors.hpp:39
Shared handle to an observable.
Definition: handle.hpp:41
Local volatility surface derived from a Black vol surface.
Volatility localVolImpl(Time, Real) const override
local vol calculation
Volatility localVolImpl(Time t, Real s) const override
local vol calculation
NoExceptLocalVolSurface(const Handle< BlackVolTermStructure > &blackTS, const Handle< YieldTermStructure > &riskFreeTS, const Handle< YieldTermStructure > &dividendTS, Real underlying, Real illegalLocalVolOverwrite)
NoExceptLocalVolSurface(const Handle< BlackVolTermStructure > &blackTS, const Handle< YieldTermStructure > &riskFreeTS, const Handle< YieldTermStructure > &dividendTS, const Handle< Quote > &underlying, Real illegalLocalVolOverwrite)
const DefaultType & t
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Real Volatility
volatility
Definition: types.hpp:78
Local volatility surface derived from a Black vol surface.
Definition: any.hpp:35