Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
blackvolsurfacewithatm.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 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 qle/termstructures/blackvolsurfacewithatm.hpp
20 \brief Wrapper class for a BlackVolTermStructure that easily exposes ATM vols.
21 \ingroup termstructures
22*/
23
24#ifndef quantext_blackvolsurfacewithatm_hpp
25#define quantext_blackvolsurfacewithatm_hpp
26
27#include <ql/shared_ptr.hpp>
28#include <ql/quote.hpp>
29#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
30#include <ql/termstructures/yieldtermstructure.hpp>
31
32namespace QuantExt {
33using namespace QuantLib;
34
35//! Wrapper class for a BlackVolTermStructure that easily exposes ATM vols.
36/*! This class implements BlackVolatilityTermStructure and takes a surface (well, any BlackVolTermStructure) as an
37 input. If asked for a volatility with strike=Null<Real>() or 0 it will calculate the forward value and use this as
38 the strike, this makes it easy to access ATMF values.
39
40 The forward value is calculated using the input spot and yield curves, so can be used for both FX and Equity vols.
41
42 For FX markets, one should set the spot to be the FX spot rate, yield1 to be the base discount curve and yield2 to
43 be the reference discount curve (e.g. EURUSD, yield1 = EUR).
44
45 For Equity markets, one should set the spot to be the equity price, yield1 to be the discount curve and yield2 to
46 be the dividend curve.
47 */
48//!\ingroup termstructures
49
50class BlackVolatilityWithATM : public BlackVolatilityTermStructure {
51public:
52 //! Constructor. This is a floating term structure (settlement days is zero)
53 BlackVolatilityWithATM(const QuantLib::ext::shared_ptr<BlackVolTermStructure>& surface, const Handle<Quote>& spot,
54 const Handle<YieldTermStructure>& yield1 = Handle<YieldTermStructure>(),
55 const Handle<YieldTermStructure>& yield2 = Handle<YieldTermStructure>());
56
57 //! \name TermStructure interface
58 //@{
59 DayCounter dayCounter() const override { return surface_->dayCounter(); }
60 Date maxDate() const override { return surface_->maxDate(); }
61 Time maxTime() const override { return surface_->maxTime(); }
62 const Date& referenceDate() const override { return surface_->referenceDate(); }
63 Calendar calendar() const override { return surface_->calendar(); }
64 Natural settlementDays() const override { return surface_->settlementDays(); }
65 //@}
66
67 //! \name VolatilityTermStructure interface
68 //@{
69 Rate minStrike() const override { return surface_->minStrike(); }
70 Rate maxStrike() const override { return surface_->maxStrike(); }
71 //@}
72
73 //! \name Inspectors
74 //@{
75 QuantLib::ext::shared_ptr<BlackVolTermStructure> surface() const { return surface_; }
76 Handle<Quote> spot() const { return spot_; }
77 Handle<YieldTermStructure> yield1() const { return yield1_; }
78 Handle<YieldTermStructure> yield2() const { return yield2_; }
79 //@}
80
81protected:
82 // Here we check if strike is Null<Real>() or 0 and calculate ATMF if so.
83 Volatility blackVolImpl(Time t, Real strike) const override;
84
85private:
86 QuantLib::ext::shared_ptr<BlackVolTermStructure> surface_;
87 Handle<Quote> spot_;
88 Handle<YieldTermStructure> yield1_, yield2_;
89};
90
91} // namespace QuantExt
92
93#endif
Wrapper class for a BlackVolTermStructure that easily exposes ATM vols.
Handle< YieldTermStructure > yield2() const
QuantLib::ext::shared_ptr< BlackVolTermStructure > surface_
QuantLib::ext::shared_ptr< BlackVolTermStructure > surface() const
const Date & referenceDate() const override
Handle< YieldTermStructure > yield1() const
DayCounter dayCounter() const override
Handle< YieldTermStructure > yield1_
Volatility blackVolImpl(Time t, Real strike) const override
Handle< YieldTermStructure > yield2_