QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
blackvariancesurface.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2002, 2003, 2004 Ferdinando Ametrano
5 Copyright (C) 2003, 2004 StatPro Italia srl
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
25#ifndef quantlib_black_variance_surface_hpp
26#define quantlib_black_variance_surface_hpp
27
28#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
29#include <ql/math/matrix.hpp>
30#include <ql/math/interpolations/interpolation2d.hpp>
31#include <ql/time/daycounters/actual365fixed.hpp>
32
33namespace QuantLib {
34
36
48 public:
52 const Calendar& cal,
53 const std::vector<Date>& dates,
54 std::vector<Real> strikes,
55 const Matrix& blackVolMatrix,
60
61 DayCounter dayCounter() const override { return dayCounter_; }
62 Date maxDate() const override { return maxDate_; }
64
66 Real minStrike() const override { return strikes_.front(); }
67 Real maxStrike() const override { return strikes_.back(); }
69
71 template <class Interpolator>
72 void setInterpolation(const Interpolator& i = Interpolator()) {
74 i.interpolate(times_.begin(), times_.end(),
75 strikes_.begin(), strikes_.end(),
78 }
80
82 void accept(AcyclicVisitor&) override;
84 protected:
85 Real blackVarianceImpl(Time t, Real strike) const override;
86
87 private:
90 std::vector<Real> strikes_;
91 std::vector<Time> times_;
95 };
96
97
98 // inline definitions
99
101 auto* v1 = dynamic_cast<Visitor<BlackVarianceSurface>*>(&v);
102 if (v1 != nullptr)
103 v1->visit(*this);
104 else
106 }
107
108}
109
110
111#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Black volatility surface modelled as variance surface.
Real minStrike() const override
the minimum strike for which the term structure can return vols
void accept(AcyclicVisitor &) override
DayCounter dayCounter() const override
the day counter used for date/time conversion
void setInterpolation(const Interpolator &i=Interpolator())
Date maxDate() const override
the latest date for which the curve can return values
Real blackVarianceImpl(Time t, Real strike) const override
Black variance calculation.
Real maxStrike() const override
the maximum strike for which the term structure can return vols
void accept(AcyclicVisitor &) override
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
base class for 2-D interpolations.
Matrix used in linear algebra.
Definition: matrix.hpp:41
virtual const Date & referenceDate() const
the date at which discount = 1.0 and/or variance = 0.0
Visitor for a specific class
Definition: visitor.hpp:40
virtual void visit(T &)=0
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35