Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
spreadedswaptionvolatility.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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 spreadedswaptionvolatility.hpp
20 \brief swaption cube defined via atm vol spreads over another cube
21 \ingroup termstructures
22*/
23
24#pragma once
25
26#include <ql/indexes/swapindex.hpp>
27#include <ql/math/interpolations/interpolation2d.hpp>
28#include <ql/quote.hpp>
29#include <ql/termstructures/volatility/smilesection.hpp>
30#include <ql/termstructures/volatility/swaption/swaptionvoldiscrete.hpp>
31
32#include <ql/shared_ptr.hpp>
33
34namespace QuantExt {
35using namespace QuantLib;
36
38public:
39 /* - The base vol is required to provide smile sections with atm levels, if there is more than one strike spread
40 given. Alternatively, baseSwapIndexBase and baseShortSwapIndexBase can be provided to compute these ATM levels.
41 - If stickyAbsMoney is true, the simulatedSwapIndexBase and simulatedShortSwapIndexBase must be provided and
42 represent an ATM level reacting to changes in rate levels. The ATM levels implied by base vol,
43 baseSwapIndexBase, baseShortSwapIndexBase must not react to changes in the rate levels on the other hand.
44 */
45 SpreadedSwaptionVolatility(const Handle<SwaptionVolatilityStructure>& base, const std::vector<Period>& optionTenors,
46 const std::vector<Period>& swapTenors, const std::vector<Real>& strikeSpreads,
47 const std::vector<std::vector<Handle<Quote>>>& volSpreads,
48 const QuantLib::ext::shared_ptr<SwapIndex>& baseSwapIndexBase = nullptr,
49 const QuantLib::ext::shared_ptr<SwapIndex>& baseShortSwapIndexBase = nullptr,
50 const QuantLib::ext::shared_ptr<SwapIndex>& simulatedSwapIndexBase = nullptr,
51 const QuantLib::ext::shared_ptr<SwapIndex>& simulatedShortSwapIndexBase = nullptr,
52 const bool stickyAbsMoney = false);
53
54 //! \name TermStructure interface
55 //@{
56 DayCounter dayCounter() const override;
57 Date maxDate() const override;
58 Time maxTime() const override;
59 const Date& referenceDate() const override;
60 Calendar calendar() const override;
61 Natural settlementDays() const override;
62 //! \name VolatilityTermStructure interface
63 //@{
64 Rate minStrike() const override;
65 Rate maxStrike() const override;
66 //@}
67 //! \name SwaptionVolatilityStructure interface
68 //@{
69 const Period& maxSwapTenor() const override;
70 VolatilityType volatilityType() const override;
71 //@}
72 //! \name Observer interface
73 //@{
74 void deepUpdate() override;
75 //@}
76 const Handle<SwaptionVolatilityStructure>& baseVol();
77
78private:
79 QuantLib::ext::shared_ptr<SmileSection> smileSectionImpl(Time optionTime, Time swapLength) const override;
80 Volatility volatilityImpl(Time optionTime, Time swapLength, Rate strike) const override;
81 Real shiftImpl(const Date& optionDate, const Period& swapTenor) const override;
82 Real shiftImpl(Time optionTime, Time swapLength) const override;
83 void performCalculations() const override;
84 Real getAtmLevel(const Real optionTime, const Real swapLength, const QuantLib::ext::shared_ptr<SwapIndex> swapIndexBase,
85 const QuantLib::ext::shared_ptr<SwapIndex> shortSwapIndexBase) const;
86
87 Handle<SwaptionVolatilityStructure> base_;
88 std::vector<Real> strikeSpreads_;
89 std::vector<std::vector<Handle<Quote>>> volSpreads_;
90 QuantLib::ext::shared_ptr<SwapIndex> baseSwapIndexBase_, baseShortSwapIndexBase_;
91 QuantLib::ext::shared_ptr<SwapIndex> simulatedSwapIndexBase_, simulatedShortSwapIndexBase_;
93 mutable std::vector<Matrix> volSpreadValues_;
94 mutable std::vector<Interpolation2D> volSpreadInterpolation_;
95};
96
97} // namespace QuantExt
QuantLib::ext::shared_ptr< SwapIndex > simulatedShortSwapIndexBase_
Real getAtmLevel(const Real optionTime, const Real swapLength, const QuantLib::ext::shared_ptr< SwapIndex > swapIndexBase, const QuantLib::ext::shared_ptr< SwapIndex > shortSwapIndexBase) const
Volatility volatilityImpl(Time optionTime, Time swapLength, Rate strike) const override
QuantLib::ext::shared_ptr< SmileSection > smileSectionImpl(Time optionTime, Time swapLength) const override
const Handle< SwaptionVolatilityStructure > & baseVol()
QuantLib::ext::shared_ptr< SwapIndex > baseSwapIndexBase_
Real shiftImpl(const Date &optionDate, const Period &swapTenor) const override
Handle< SwaptionVolatilityStructure > base_
VolatilityType volatilityType() const override
QuantLib::ext::shared_ptr< SwapIndex > simulatedSwapIndexBase_
std::vector< Interpolation2D > volSpreadInterpolation_
std::vector< std::vector< Handle< Quote > > > volSpreads_
const Period & maxSwapTenor() const override
QuantLib::ext::shared_ptr< SwapIndex > baseShortSwapIndexBase_