QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
fixedlocalvolsurface.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 Johannes Göttker-Schnetmann
5 Copyright (C) 2015 Klaus Spanderen
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
21/*! \file fixedlocalvolsurface.hpp
22 \brief Local volatility surface based on fixed values plus interpolation
23*/
24
25#ifndef quantlib_fixed_local_vol_surface_hpp
26#define quantlib_fixed_local_vol_surface_hpp
27
28#include <ql/math/matrix.hpp>
31
33
34namespace QuantLib {
35
37 public:
41 const std::vector<Date>& dates,
42 const std::vector<Real>& strikes,
43 ext::shared_ptr<Matrix> localVolMatrix,
45 Extrapolation lowerExtrapolation = ConstantExtrapolation,
46 Extrapolation upperExtrapolation = ConstantExtrapolation);
47
49 const std::vector<Time>& times,
50 const std::vector<Real>& strikes,
51 ext::shared_ptr<Matrix> localVolMatrix,
53 Extrapolation lowerExtrapolation = ConstantExtrapolation,
54 Extrapolation upperExtrapolation = ConstantExtrapolation);
55
57 const std::vector<Time>& times,
58 const std::vector<ext::shared_ptr<std::vector<Real> > >& strikes,
59 ext::shared_ptr<Matrix> localVolMatrix,
61 Extrapolation lowerExtrapolation = ConstantExtrapolation,
62 Extrapolation upperExtrapolation = ConstantExtrapolation);
63
64
65 Date maxDate() const override;
66 Time maxTime() const override;
67 Real minStrike() const override;
68 Real maxStrike() const override;
69
70 template <class Interpolator>
71 void setInterpolation(const Interpolator& i = Interpolator()) {
72 for (Size j=0; j < times_.size(); ++j) {
73 localVolInterpol_[j] = i.interpolate(
74 strikes_[j]->begin(), strikes_[j]->end(),
75 localVolMatrix_->column_begin(j));
76 }
78 }
79
80 protected:
81 Volatility localVolImpl(Time t, Real strike) const override;
82
84 std::vector<Time> times_;
85 const ext::shared_ptr<Matrix> localVolMatrix_;
86 const std::vector<ext::shared_ptr<std::vector<Real> > > strikes_;
87
88 std::vector<Interpolation> localVolInterpol_;
90
91 private:
92 void checkSurface();
93 };
94}
95
96#endif
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
std::vector< Interpolation > localVolInterpol_
Real minStrike() const override
the minimum strike for which the term structure can return vols
Volatility localVolImpl(Time t, Real strike) const override
local vol calculation
const std::vector< ext::shared_ptr< std::vector< Real > > > strikes_
const ext::shared_ptr< Matrix > localVolMatrix_
void setInterpolation(const Interpolator &i=Interpolator())
Date maxDate() const override
the latest date for which the curve can return values
Real maxStrike() const override
the maximum strike for which the term structure can return vols
Time maxTime() const override
the latest time for which the curve can return values
virtual const Date & referenceDate() const
the date at which discount = 1.0 and/or variance = 0.0
virtual DayCounter dayCounter() const
the day counter used for date/time conversion
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
std::size_t Size
size of a container
Definition: types.hpp:58
base class for 1-D interpolations
linear interpolation between discrete points
Local volatility term structure base class.
matrix used in linear algebra.
Definition: any.hpp:35