Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fxblackvolsurface.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 fxblackvolsurface.hpp
20 \brief FX Black volatility surface that incorporates an FxSmile
21 \ingroup termstructures
22*/
23
24#ifndef quantext_fx_black_vol_surface_hpp
25#define quantext_fx_black_vol_surface_hpp
26
27#include <ql/experimental/fx/deltavolquote.hpp>
28#include <ql/math/interpolation.hpp>
29#include <ql/termstructures/volatility/equityfx/blackvariancecurve.hpp>
30#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
31#include <ql/termstructures/yieldtermstructure.hpp>
33
34namespace QuantExt {
35using namespace QuantLib;
36
37//! Fx Black volatility surface
38/*! This class calculates time/strike dependent Black volatilities
39 \ingroup termstructures
40*/
41class FxBlackVolatilitySurface : public BlackVolatilityTermStructure {
42public:
43 FxBlackVolatilitySurface(const Date& referenceDate, const std::vector<Date>& dates,
44 const std::vector<Volatility>& atmVols, const std::vector<Volatility>& rr,
45 const std::vector<Volatility>& bf, const DayCounter& dayCounter, const Calendar& cal,
46 const Handle<Quote>& fxSpot, const Handle<YieldTermStructure>& domesticTS,
47 const Handle<YieldTermStructure>& foreignTS, bool requireMonotoneVariance = true,
48 const DeltaVolQuote::AtmType atmType = DeltaVolQuote::AtmType::AtmDeltaNeutral,
49 const DeltaVolQuote::DeltaType deltaType = DeltaVolQuote::DeltaType::Spot,
50 const Real delta = 0.25, const Period& switchTenor = 0 * Days,
51 const DeltaVolQuote::AtmType longTermAtmType = DeltaVolQuote::AtmType::AtmDeltaNeutral,
52 const DeltaVolQuote::DeltaType longTermDeltaType = DeltaVolQuote::DeltaType::Spot);
53
54 //! \name TermStructure interface
55 //@{
56 DayCounter dayCounter() const override { return dayCounter_; }
57 Date maxDate() const override { return maxDate_; }
58 //@}
59 //! \name VolatilityTermStructure interface
60 //@{
61 Real minStrike() const override { return 0; } // we allow 0 for ATM vols
62 Real maxStrike() const override { return QL_MAX_REAL; }
63 //@}
64 //! \name Visitability
65 //@{
66 virtual void accept(AcyclicVisitor&) override;
67 //@}
68 //! Return an FxSmile for the time t
69 /*! Note the smile does not observe the spot or YTS handles, it will
70 * not update when they change
71 */
72 QuantLib::ext::shared_ptr<FxSmileSection> blackVolSmile(Time t) const;
73
74protected:
75 virtual Volatility blackVolImpl(Time t, Real strike) const override;
76
77 //! this must be implemented.
78 virtual QuantLib::ext::shared_ptr<FxSmileSection> blackVolSmileImpl(Real spot, Real rd, Real rf, Time t, Volatility atm,
79 Volatility rr, Volatility bf) const = 0;
80
81 std::vector<Time> times_;
82 DayCounter dayCounter_;
83 Handle<Quote> fxSpot_;
84 Handle<YieldTermStructure> domesticTS_;
85 Handle<YieldTermStructure> foreignTS_;
86 BlackVarianceCurve atmCurve_;
87 std::vector<Volatility> rr_;
88 std::vector<Volatility> bf_;
89 DeltaVolQuote::AtmType atmType_;
90 DeltaVolQuote::DeltaType deltaType_;
91 Real delta_;
93 DeltaVolQuote::AtmType longTermAtmType_;
94 DeltaVolQuote::DeltaType longTermDeltaType_;
95 Interpolation rrCurve_;
96 Interpolation bfCurve_;
98};
99
100// inline definitions
101inline void FxBlackVolatilitySurface::accept(AcyclicVisitor& v) {
102 Visitor<FxBlackVolatilitySurface>* v1 = dynamic_cast<Visitor<FxBlackVolatilitySurface>*>(&v);
103 if (v1 != 0)
104 v1->visit(*this);
105 else
106 BlackVolatilityTermStructure::accept(v);
107}
108
109//! Fx Black vanna volga volatility surface
110/*! This class calculates time/strike dependent Black volatilities
111 \ingroup termstructures
112*/
114public:
116 const Date& refDate, const std::vector<Date>& dates, const std::vector<Volatility>& atmVols,
117 const std::vector<Volatility>& rr, const std::vector<Volatility>& bf, const DayCounter& dc, const Calendar& cal,
118 const Handle<Quote>& fx, const Handle<YieldTermStructure>& dom, const Handle<YieldTermStructure>& fore,
119 bool requireMonotoneVariance = true, const bool firstApprox = false,
120 const DeltaVolQuote::AtmType atmType = DeltaVolQuote::AtmType::AtmDeltaNeutral,
121 const DeltaVolQuote::DeltaType deltaType = DeltaVolQuote::DeltaType::Spot, const Real delta = 0.25,
122 const Period& switchTenor = 0 * Days,
123 const DeltaVolQuote::AtmType longTermAtmType = DeltaVolQuote::AtmType::AtmDeltaNeutral,
124 const DeltaVolQuote::DeltaType longTermDeltaType = DeltaVolQuote::DeltaType::Spot)
125 : FxBlackVolatilitySurface(refDate, dates, atmVols, rr, bf, dc, cal, fx, dom, fore, requireMonotoneVariance,
126 atmType, deltaType, delta, switchTenor, longTermAtmType, longTermDeltaType),
127 firstApprox_(firstApprox) {}
128
129protected:
131 virtual QuantLib::ext::shared_ptr<FxSmileSection> blackVolSmileImpl(Real spot, Real rd, Real rf, Time t, Volatility atm,
132 Volatility rr, Volatility bf) const override;
133};
134} // namespace QuantExt
135
136#endif
Fx Black vanna volga volatility surface.
FxBlackVannaVolgaVolatilitySurface(const Date &refDate, const std::vector< Date > &dates, const std::vector< Volatility > &atmVols, const std::vector< Volatility > &rr, const std::vector< Volatility > &bf, const DayCounter &dc, const Calendar &cal, const Handle< Quote > &fx, const Handle< YieldTermStructure > &dom, const Handle< YieldTermStructure > &fore, bool requireMonotoneVariance=true, const bool firstApprox=false, const DeltaVolQuote::AtmType atmType=DeltaVolQuote::AtmType::AtmDeltaNeutral, const DeltaVolQuote::DeltaType deltaType=DeltaVolQuote::DeltaType::Spot, const Real delta=0.25, const Period &switchTenor=0 *Days, const DeltaVolQuote::AtmType longTermAtmType=DeltaVolQuote::AtmType::AtmDeltaNeutral, const DeltaVolQuote::DeltaType longTermDeltaType=DeltaVolQuote::DeltaType::Spot)
virtual QuantLib::ext::shared_ptr< FxSmileSection > blackVolSmileImpl(Real spot, Real rd, Real rf, Time t, Volatility atm, Volatility rr, Volatility bf) const override
this must be implemented.
Fx Black volatility surface.
virtual QuantLib::ext::shared_ptr< FxSmileSection > blackVolSmileImpl(Real spot, Real rd, Real rf, Time t, Volatility atm, Volatility rr, Volatility bf) const =0
this must be implemented.
Handle< YieldTermStructure > foreignTS_
virtual void accept(AcyclicVisitor &) override
Handle< YieldTermStructure > domesticTS_
QuantLib::ext::shared_ptr< FxSmileSection > blackVolSmile(Time t) const
Return an FxSmile for the time t.
DayCounter dayCounter() const override
DeltaVolQuote::AtmType longTermAtmType_
virtual Volatility blackVolImpl(Time t, Real strike) const override
DeltaVolQuote::DeltaType deltaType_
DeltaVolQuote::DeltaType longTermDeltaType_
FX smile section assuming a strike/volatility space using vanna volga method.