QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
blackvariancecurve.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 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_curve_hpp
26#define quantlib_black_variance_curve_hpp
27
28#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
29#include <ql/math/interpolation.hpp>
30
31namespace QuantLib {
32
34
48 public:
50 const std::vector<Date>& dates,
51 const std::vector<Volatility>& blackVolCurve,
53 bool forceMonotoneVariance = true);
55
56 DayCounter dayCounter() const override { return dayCounter_; }
57 Date maxDate() const override;
59
61 Real minStrike() const override;
62 Real maxStrike() const override;
64
66 template <class Interpolator>
67 void setInterpolation(const Interpolator& i = Interpolator()) {
68 varianceCurve_ = i.interpolate(times_.begin(), times_.end(),
69 variances_.begin());
72 }
74
76 void accept(AcyclicVisitor&) override;
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
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
#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
Definition: any.hpp:35