Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
blackvariancesurfacesparse.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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 blackvariancesurfacesparse.hpp
20 \brief Black volatility surface modeled as variance surface
21 */
22
23#ifndef quantext_black_variance_surface_sparse_hpp
24#define quantext_black_variance_surface_sparse_hpp
25
26#include <ql/math/interpolations/linearinterpolation.hpp>
27#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
28#include <ql/time/daycounters/actual365fixed.hpp>
30
31namespace QuantExt {
32
33//! Black volatility surface based on sparse matrix.
34//! \ingroup termstructures
35class BlackVarianceSurfaceSparse : public QuantLib::BlackVarianceTermStructure,
36 public OptionInterpolator2d<QuantLib::Linear, QuantLib::Linear> {
37
38public:
39 BlackVarianceSurfaceSparse(const QuantLib::Date& referenceDate, const QuantLib::Calendar& cal,
40 const std::vector<QuantLib::Date>& dates, const std::vector<QuantLib::Real>& strikes,
41 const std::vector<QuantLib::Volatility>& volatilities,
42 const QuantLib::DayCounter& dayCounter, bool lowerStrikeConstExtrap = true,
43 bool upperStrikeConstExtrap = true, bool timeFlatExtrapolation = false);
44
46 //! \name TermStructure interface
47 //@{
48 QuantLib::Date maxDate() const override { return QuantLib::Date::maxDate(); }
49 const QuantLib::Date& referenceDate() const override { return OptionInterpolator2d::referenceDate(); }
50 QuantLib::DayCounter dayCounter() const override { return OptionInterpolator2d::dayCounter(); }
51 //@}
52 //! \name VolatilityTermStructure interface
53 //@{
54 QuantLib::Real minStrike() const override { return 0; }
55 QuantLib::Real maxStrike() const override { return QL_MAX_REAL; }
56 //@}
57
58 //! \name Visitability
59 //@{
60 virtual void accept(QuantLib::AcyclicVisitor&) override;
61 //@}
62
63protected:
64 virtual QuantLib::Real blackVarianceImpl(QuantLib::Time t, QuantLib::Real strike) const override;
65
67};
68
69// inline definitions
70
71inline void BlackVarianceSurfaceSparse::accept(QuantLib::AcyclicVisitor& v) {
72 QuantLib::Visitor<BlackVarianceSurfaceSparse>* v1 =
73 dynamic_cast<QuantLib::Visitor<BlackVarianceSurfaceSparse>*>(&v);
74 if (v1 != 0)
75 v1->visit(*this);
76 else
77 QuantLib::BlackVarianceTermStructure::accept(v);
78}
79} // namespace QuantExt
80
81#endif
virtual QuantLib::Real blackVarianceImpl(QuantLib::Time t, QuantLib::Real strike) const override
virtual void accept(QuantLib::AcyclicVisitor &) override
QuantLib::DayCounter dayCounter() const override
const QuantLib::Date & referenceDate() const override
std::vector< std::vector< QuantLib::Real > > strikes() const
QuantLib::DayCounter dayCounter() const
const QuantLib::Date & referenceDate() const