Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
blackvolsurfacedelta.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 Quaternion Risk Management Ltd
3 Copyright (C) 2022 Skandinaviska Enskilda Banken AB (publ)
4 All rights reserved.
5
6 This file is part of ORE, a free-software/open-source library
7 for transparent pricing and risk analysis - http://opensourcerisk.org
8
9 ORE is free software: you can redistribute it and/or modify it
10 under the terms of the Modified BSD License. You should have received a
11 copy of the license along with this program.
12 The license is also available online at <http://opensourcerisk.org>
13
14 This program is distributed on the basis that it will form a useful
15 contribution to risk analytics and model standardisation, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file blackvolsurfacedelta.hpp
21 \brief Black volatility surface based on delta
22 \ingroup termstructures
23 */
24
25#ifndef quantext_black_variance_surface_delta_hpp
26#define quantext_black_variance_surface_delta_hpp
27
28#include <ql/experimental/fx/deltavolquote.hpp>
29#include <ql/math/interpolation.hpp>
30#include <ql/math/matrix.hpp>
31#include <ql/termstructures/volatility/equityfx/blackvariancecurve.hpp>
32#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
33#include <ql/termstructures/yieldtermstructure.hpp>
34#include <ql/time/calendar.hpp>
35#include <ql/time/daycounter.hpp>
37
38namespace QuantExt {
39using namespace QuantLib;
40
42public:
43 //! Supported interpolation methods
45
46 //! ctor
47 InterpolatedSmileSection(Real spot, Real rd, Real rf, Time t, const std::vector<Real>& strikes,
48 const std::vector<Volatility>& vols, InterpolationMethod method,
49 bool flatExtrapolation = false);
50
51 Volatility volatility(Real strike) const override;
52
53 //! \name Inspectors
54 //@{
55 const std::vector<Real>& strikes() const { return strikes_; }
56 const std::vector<Volatility>& volatilities() const { return vols_; }
57 //@}
58
59private:
60 Interpolation interpolator_;
61 std::vector<Real> strikes_;
62 std::vector<Volatility> vols_;
64};
65
67public:
68 //! ctor
69 ConstantSmileSection(const Volatility vol) : vol_(vol) {}
70
71 Volatility volatility(Real strike) const override { return vol_; }
72
73 //! \name Inspectors
74 //@{
75 const Volatility volatility() const { return vol_; }
76 //@}
77
78private:
79 Volatility vol_;
80};
81
82//! Abstract Black volatility surface based on delta
83//! \ingroup termstructures
84class BlackVolatilitySurfaceDelta : public BlackVolatilityTermStructure {
85public:
86 BlackVolatilitySurfaceDelta(Date referenceDate, const std::vector<Date>& dates, const std::vector<Real>& putDeltas,
87 const std::vector<Real>& callDeltas, bool hasAtm, const Matrix& blackVolMatrix,
88 const DayCounter& dayCounter, const Calendar& cal, const Handle<Quote>& spot,
89 const Handle<YieldTermStructure>& domesticTS,
90 const Handle<YieldTermStructure>& foreignTS,
91 DeltaVolQuote::DeltaType dt = DeltaVolQuote::DeltaType::Spot,
92 DeltaVolQuote::AtmType at = DeltaVolQuote::AtmType::AtmDeltaNeutral,
93 boost::optional<QuantLib::DeltaVolQuote::DeltaType> atmDeltaType = boost::none,
94 const Period& switchTenor = 0 * Days,
95 DeltaVolQuote::DeltaType ltdt = DeltaVolQuote::DeltaType::Fwd,
96 DeltaVolQuote::AtmType ltat = DeltaVolQuote::AtmType::AtmDeltaNeutral,
97 boost::optional<QuantLib::DeltaVolQuote::DeltaType> longTermAtmDeltaType = boost::none,
100 bool flatExtrapolation = true);
101
102 //! \name TermStructure interface
103 //@{
104 Date maxDate() const override { return Date::maxDate(); }
105 //@}
106 //! \name VolatilityTermStructure interface
107 //@{
108 Real minStrike() const override { return 0; }
109 Real maxStrike() const override { return QL_MAX_REAL; }
110 //@}
111 //! \name Visitability
112 //@{
113 virtual void accept(AcyclicVisitor&) override;
114 //@}
115
116 //! \name Inspectors
117 //@{
118 const std::vector<QuantLib::Date>& dates() const { return dates_; }
119 //@}
120
121 //! Return an FxSmile for the time t
122 /*! Note the smile does not observe the spot or YTS handles, it will
123 * not update when they change.
124 *
125 * This is not really FX specific
126 */
127 QuantLib::ext::shared_ptr<FxSmileSection> blackVolSmile(Time t) const;
128
129 QuantLib::ext::shared_ptr<FxSmileSection> blackVolSmile(const QuantLib::Date& d) const;
130
131protected:
132 virtual Volatility blackVolImpl(Time t, Real strike) const override;
133
134private:
135 std::vector<Date> dates_;
136 std::vector<Time> times_;
137
138 std::vector<Real> putDeltas_;
139 std::vector<Real> callDeltas_;
141 std::vector<QuantLib::ext::shared_ptr<BlackVarianceCurve> > interpolators_;
142
143 Handle<Quote> spot_;
144 Handle<YieldTermStructure> domesticTS_;
145 Handle<YieldTermStructure> foreignTS_;
146
147 DeltaVolQuote::DeltaType dt_;
148 DeltaVolQuote::AtmType at_;
149 boost::optional<QuantLib::DeltaVolQuote::DeltaType> atmDeltaType_;
151 DeltaVolQuote::DeltaType ltdt_;
152 DeltaVolQuote::AtmType ltat_;
153 boost::optional<QuantLib::DeltaVolQuote::DeltaType> longTermAtmDeltaType_;
154
157
159
160 // calculate forward for time $t$
161 Real forward(Time t) const;
162};
163
164// inline definitions
165
166inline void BlackVolatilitySurfaceDelta::accept(AcyclicVisitor& v) {
167 Visitor<BlackVolatilitySurfaceDelta>* v1 = dynamic_cast<Visitor<BlackVolatilitySurfaceDelta>*>(&v);
168 if (v1 != 0)
169 v1->visit(*this);
170 else
171 BlackVolatilityTermStructure::accept(v);
172}
173
174} // namespace QuantExt
175
176#endif
QuantLib::ext::shared_ptr< FxSmileSection > blackVolSmile(const QuantLib::Date &d) const
boost::optional< QuantLib::DeltaVolQuote::DeltaType > atmDeltaType_
std::vector< QuantLib::ext::shared_ptr< BlackVarianceCurve > > interpolators_
virtual void accept(AcyclicVisitor &) override
Handle< YieldTermStructure > domesticTS_
QuantLib::ext::shared_ptr< FxSmileSection > blackVolSmile(Time t) const
Return an FxSmile for the time t.
boost::optional< QuantLib::DeltaVolQuote::DeltaType > longTermAtmDeltaType_
InterpolatedSmileSection::InterpolationMethod interpolationMethod_
virtual Volatility blackVolImpl(Time t, Real strike) const override
const std::vector< QuantLib::Date > & dates() const
const Volatility volatility() const
Volatility volatility(Real strike) const override
ConstantSmileSection(const Volatility vol)
ctor
Volatility volatility(Real strike) const override
const std::vector< Real > & strikes() const
InterpolationMethod
Supported interpolation methods.
const std::vector< Volatility > & volatilities() const
FX smile section assuming a strike/volatility space.