QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
blackvariancecurve.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) 2002, 2003, 2004 Ferdinando Ametrano
5 Copyright (C) 2003 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
21/*! \file blackvariancecurve.hpp
22 \brief Black volatility curve modelled as variance curve
23*/
24
25#ifndef quantlib_black_variance_curve_hpp
26#define quantlib_black_variance_curve_hpp
27
30
31namespace QuantLib {
32
33 //! Black volatility curve modelled as variance curve
34 /*! This class calculates time-dependent Black volatilities using
35 as input a vector of (ATM) Black volatilities observed in the
36 market.
37
38 The calculation is performed interpolating on the variance curve.
39 Linear interpolation is used as default; this can be changed
40 by the setInterpolation() method.
41
42 For strike dependence, see BlackVarianceSurface.
43
44 \todo check time extrapolation
45
46 */
48 public:
50 const std::vector<Date>& dates,
51 const std::vector<Volatility>& blackVolCurve,
53 bool forceMonotoneVariance = true);
54 //! \name TermStructure interface
55 //@{
56 DayCounter dayCounter() const override { return dayCounter_; }
57 Date maxDate() const override;
58 //@}
59 //! \name VolatilityTermStructure interface
60 //@{
61 Real minStrike() const override;
62 Real maxStrike() const override;
63 //@}
64 //! \name Modifiers
65 //@{
66 template <class Interpolator>
67 void setInterpolation(const Interpolator& i = Interpolator()) {
68 varianceCurve_ = i.interpolate(times_.begin(), times_.end(),
69 variances_.begin());
72 }
73 //@}
74 //! \name Visitability
75 //@{
76 void accept(AcyclicVisitor&) override;
77 //@}
78 protected:
79 Real blackVarianceImpl(Time t, Real) const override;
80
81 private:
84 std::vector<Time> times_;
85 std::vector<Real> variances_;
87 };
88
89
90 // inline definitions
91
93 return maxDate_;
94 }
95
97 return QL_MIN_REAL;
98 }
99
101 return QL_MAX_REAL;
102 }
103
105 auto* v1 = dynamic_cast<Visitor<BlackVarianceCurve>*>(&v);
106 if (v1 != nullptr)
107 v1->visit(*this);
108 else
110 }
111
112}
113
114#endif
Black volatility term structure base classes.
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Black volatility curve modelled as variance curve.
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) const override
Black variance calculation.
Real maxStrike() const override
the maximum strike for which the term structure can return vols
void accept(AcyclicVisitor &) override
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
base class for 1-D interpolations.
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
const DefaultType & t
#define QL_MAX_REAL
Definition: qldefines.hpp:176
#define QL_MIN_REAL
Definition: qldefines.hpp:175
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
base class for 1-D interpolations
Definition: any.hpp:35
ext::shared_ptr< BlackVolTermStructure > v