QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
extendedblackvariancesurface.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) 2008 Frank Hövermann
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 extendedblackvariancesurface.hpp
21 \brief Black volatility surface modelled as variance surface
22*/
23
24#ifndef quantlib_extended_black_variance_surface_hpp
25#define quantlib_extended_black_variance_surface_hpp
26
28#include <ql/math/matrix.hpp>
30#include <ql/handle.hpp>
31#include <ql/quote.hpp>
32
33namespace QuantLib {
34
35 //! Black volatility surface modelled as variance surface
36 /*! This class is similar to BlackVarianceSurface, but extends it
37 to use quotes for the input volatilities.
38 */
40 public:
44 const Date& referenceDate,
45 const Calendar& calendar,
46 const std::vector<Date>& dates,
47 std::vector<Real> strikes,
48 const std::vector<Handle<Quote> >& volatilities,
52 DayCounter dayCounter() const override { return dayCounter_; }
53 Date maxDate() const override { return maxDate_; }
54 Real minStrike() const override { return strikes_.front(); }
55 Real maxStrike() const override { return strikes_.back(); }
56 template <class Interpolator>
57 void setInterpolation(const Interpolator& i = Interpolator()) {
59 i.interpolate(times_.begin(), times_.end(),
60 strikes_.begin(), strikes_.end(),
64 }
65 void accept(AcyclicVisitor&) override;
66 void update() override;
67
68 private:
69 Real blackVarianceImpl(Time t, Real strike) const override;
70 void setVariances();
73 const std::vector<Handle<Quote> >& volatilities_;
74 std::vector<Real> strikes_;
75 std::vector<Time> times_;
79 };
80
82 auto* v1 = dynamic_cast<Visitor<ExtendedBlackVarianceSurface>*>(&v);
83 if (v1 != nullptr)
84 v1->visit(*this);
85 else
87 }
88
89}
90
91#endif
Black volatility term structure base classes.
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
void accept(AcyclicVisitor &) override
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Black volatility surface modelled as variance surface.
const std::vector< Handle< Quote > > & volatilities_
Real minStrike() const override
the minimum strike for which the term structure can return vols
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
Shared handle to an observable.
Definition: handle.hpp:41
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
virtual Calendar calendar() const
the calendar used for reference and/or option date calculation
Visitor for a specific class
Definition: visitor.hpp:40
virtual void visit(T &)=0
const DefaultType & t
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Globally accessible relinkable pointer.
abstract base classes for 2-D interpolations
matrix used in linear algebra.
Definition: any.hpp:35
ext::shared_ptr< BlackVolTermStructure > v
purely virtual base class for market observables