Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
blackinvertedvoltermstructure.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 blackinvertedvoltermstructure.hpp
20 \brief Black volatility surface that inverts an existing surface.
21 \ingroup termstructures
22*/
23
24#ifndef quantext_black_inverted_vol_termstructure_hpp
25#define quantext_black_inverted_vol_termstructure_hpp
26
27#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
28
29namespace QuantExt {
30using namespace QuantLib;
31
32//! Black volatility surface that inverts an existing surface.
33/*! This class is used when one wants a USD/EUR volatility, at a given USD/EUR strike
34 when only a EUR/USD volatility surface is present.
35
36 \ingroup termstructures
37*/
39public:
40 //! Constructor takes a BlackVolTermStructure and takes everything from that
41 /*! This will work with both a floating and fixed reference date underlying surface,
42 since we are reimplementing the reference date and update methods */
43 BlackInvertedVolTermStructure(const Handle<BlackVolTermStructure>& vol)
44 : BlackVolTermStructure(vol->businessDayConvention(), vol->dayCounter()), vol_(vol) {
45 registerWith(vol_);
46 }
47
48 //! return the underlying vol surface
49 const Handle<BlackVolTermStructure>& underlyingVol() const { return vol_; }
50
51 //! \name TermStructure interface
52 //@{
53 const Date& referenceDate() const override { return vol_->referenceDate(); }
54 Date maxDate() const override { return vol_->maxDate(); }
55 Natural settlementDays() const override { return vol_->settlementDays(); }
56 Calendar calendar() const override { return vol_->calendar(); }
57 //! \name Observer interface
58 //@{
59 void update() override { notifyObservers(); }
60 //@}
61 //! \name VolatilityTermStructure interface
62 //@{
63 Real minStrike() const override {
64 Real min = vol_->minStrike();
65 if (min == QL_MIN_REAL || min == 0)
66 return 0; // we allow ATM calls
67 else
68 return 1 / vol_->maxStrike();
69 }
70 Real maxStrike() const override {
71 Real min = vol_->minStrike();
72 if (min == QL_MIN_REAL || min == 0)
73 return QL_MAX_REAL;
74 else
75 return 1 / min;
76 }
77 //@}
78 //! \name Visitability
79 //@{
80 virtual void accept(AcyclicVisitor&) override;
81 //@}
82protected:
83 // we pass through non-reciprocal values (0 and Null<Real>) assuming they mean ATMF.
84 Real invertedStrike(Real strike) const { return (strike == 0.0 || strike == Null<Real>()) ? strike : 1.0 / strike; }
85 virtual Real blackVarianceImpl(Time t, Real strike) const override { return vol_->blackVariance(t, invertedStrike(strike)); }
86 virtual Volatility blackVolImpl(Time t, Real strike) const override { return vol_->blackVol(t, invertedStrike(strike)); }
87
88private:
89 Handle<BlackVolTermStructure> vol_;
90};
91
92// inline definitions
93inline void BlackInvertedVolTermStructure::accept(AcyclicVisitor& v) {
94 Visitor<BlackInvertedVolTermStructure>* v1 = dynamic_cast<Visitor<BlackInvertedVolTermStructure>*>(&v);
95 if (v1 != 0)
96 v1->visit(*this);
97 else
99}
100} // namespace QuantExt
101
102#endif
Black volatility surface that inverts an existing surface.
const Handle< BlackVolTermStructure > & underlyingVol() const
return the underlying vol surface
BlackInvertedVolTermStructure(const Handle< BlackVolTermStructure > &vol)
Constructor takes a BlackVolTermStructure and takes everything from that.
virtual void accept(AcyclicVisitor &) override
virtual Volatility blackVolImpl(Time t, Real strike) const override
virtual Real blackVarianceImpl(Time t, Real strike) const override
CompiledFormula min(CompiledFormula x, const CompiledFormula &y)