Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
blackvariancecurve3.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file blackvariancecurve3.hpp
20 \brief Black volatility curve modeled as variance curve
21 \ingroup termstructures
22*/
23
24#ifndef quantext_black_variance_curve_3_hpp
25#define quantext_black_variance_curve_3_hpp
26
27#include <ql/math/interpolation.hpp>
28#include <ql/patterns/lazyobject.hpp>
29#include <ql/quote.hpp>
30#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
31
32namespace QuantExt {
33using namespace QuantLib;
34
35//! Black volatility curve modeled as variance curve
36/*! This class calculates time-dependent Black volatilities using
37 as input a vector of (ATM) Black volatilities observed in the
38 market.
39
40 The calculation is performed interpolating on the variance curve.
41 Linear interpolation is used.
42
43 \todo check time extrapolation
44
45 \ingroup termstructures
46*/
47class BlackVarianceCurve3 : public LazyObject, public BlackVarianceTermStructure {
48public:
49 // If requireMonotoneVariance is true, we check for monotone variance in performCalculations and throw if not
50 BlackVarianceCurve3(Natural settlementDays, const Calendar& cal, BusinessDayConvention bdc, const DayCounter& dc,
51 const std::vector<Time>& times, const std::vector<Handle<Quote> >& blackVolCurve,
52 bool requireMonotoneVariance = true);
53 //! \name TermStructure interface
54 //@{
55 Date maxDate() const override;
56 //@}
57 //! \name VolatilityTermStructure interface
58 //@{
59 Real minStrike() const override;
60 Real maxStrike() const override;
61 //@}
62 //! \name Observer interface
63 //@{
64 void update() override;
65 //@}
66 //! \name LazyObject interface
67 //@{
68 void performCalculations() const override;
69 //@}
70 //! \name Visitability
71 //@{
72 virtual void accept(AcyclicVisitor&) override;
73 //@}
74protected:
75 virtual Real blackVarianceImpl(Time t, Real) const override;
76
77private:
78 std::vector<Time> times_;
79 std::vector<Handle<Quote> > quotes_;
80 mutable std::vector<Real> variances_;
81 mutable Interpolation varianceCurve_;
83};
84
85// inline definitions
86
87inline Date BlackVarianceCurve3::maxDate() const { return Date::maxDate(); }
88
89inline Real BlackVarianceCurve3::minStrike() const { return QL_MIN_REAL; }
90
91inline Real BlackVarianceCurve3::maxStrike() const { return QL_MAX_REAL; }
92
93inline void BlackVarianceCurve3::accept(AcyclicVisitor& v) {
94 Visitor<BlackVarianceCurve3>* v1 = dynamic_cast<Visitor<BlackVarianceCurve3>*>(&v);
95 if (v1 != 0)
96 v1->visit(*this);
97 else
98 BlackVarianceTermStructure::accept(v);
99}
100} // namespace QuantExt
101
102#endif
Black volatility curve modeled as variance curve.
void performCalculations() const override
virtual void accept(AcyclicVisitor &) override
std::vector< Handle< Quote > > quotes_
virtual Real blackVarianceImpl(Time t, Real) const override