Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
swaptionvolconstantspread.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/swaptionvolconstantspread.hpp
20 \brief swaption cube that combines an ATM matrix and vol spreads from a cube
21 \ingroup termstructures
22*/
23
24#ifndef quantext_swaptionvolcubeconstantspread_hpp
25#define quantext_swaptionvolcubeconstantspread_hpp
26
27#include <ql/termstructures/volatility/swaption/swaptionvolcube.hpp>
28
29#include <ql/shared_ptr.hpp>
30
31namespace QuantExt {
32using namespace QuantLib;
33
34class ConstantSpreadSmileSection : public SmileSection {
35public:
36 ConstantSpreadSmileSection(const Handle<SwaptionVolatilityStructure>& atm,
37 const Handle<SwaptionVolatilityStructure>& cube, const Real optionTime,
38 const Real swapLength)
39 : SmileSection(optionTime, DayCounter(), atm->volatilityType(),
40 atm->volatilityType() == ShiftedLognormal ? atm->shift(optionTime, swapLength) : 0.0),
41 atm_(atm), cube_(cube), swapLength_(swapLength), section_(cube_->smileSection(optionTime, swapLength_)),
43 registerWith(atm_);
44 registerWith(cube_);
45 }
46 Rate minStrike() const override { return cube_->minStrike(); }
47 Rate maxStrike() const override { return cube_->maxStrike(); }
48 Rate atmLevel() const override { return Null<Real>(); }
49
50protected:
51 Volatility volatilityImpl(Rate strike) const override;
52
53private:
54 const Handle<SwaptionVolatilityStructure> atm_, cube_;
55 const Real swapLength_;
56 const QuantLib::ext::shared_ptr<SmileSection> section_;
57 const Real atmStrike_;
58};
59
60//! Swaption cube that combines an ATM matrix and vol spreads from a cube
61/*! Notice that the TS has a floating reference date and accesses the source TS only via
62 their time-based volatility methods.
63
64 \warning the given atm vol structure should be strike independent, this is not checked
65 \warning the given cube must provide smile sections that provide an ATM level
66
67 \ingroup termstructures
68*/
69class SwaptionVolatilityConstantSpread : public SwaptionVolatilityStructure {
70public:
71 SwaptionVolatilityConstantSpread(const Handle<SwaptionVolatilityStructure>& atm,
72 const Handle<SwaptionVolatilityStructure>& cube)
73 : SwaptionVolatilityStructure(0, atm->calendar(), atm->businessDayConvention(), atm->dayCounter()), atm_(atm),
74 cube_(cube) {
75 enableExtrapolation(atm->allowsExtrapolation());
76 registerWith(atm_);
77 registerWith(cube_);
78 }
79
80 //! \name TermStructure interface
81 //@{
82 DayCounter dayCounter() const override { return atm_->dayCounter(); }
83 Date maxDate() const override { return atm_->maxDate(); }
84 Time maxTime() const override { return atm_->maxTime(); }
85 const Date& referenceDate() const override { return atm_->referenceDate(); }
86 Calendar calendar() const override { return atm_->calendar(); }
87 Natural settlementDays() const override { return atm_->settlementDays(); }
88 //! \name VolatilityTermStructure interface
89 //@{
90 Rate minStrike() const override { return cube_->minStrike(); }
91 Rate maxStrike() const override { return cube_->maxStrike(); }
92 //@}
93 //! \name SwaptionVolatilityStructure interface
94 //@{
95 const Period& maxSwapTenor() const override { return atm_->maxSwapTenor(); }
96 VolatilityType volatilityType() const override { return atm_->volatilityType(); }
97 //@}
98 //! \name Observer interface
99 //@{
100 void deepUpdate() override;
101 //@}
102 const Handle<SwaptionVolatilityStructure>& atmVol() { return atm_; }
103 const Handle<SwaptionVolatilityStructure>& cube() { return cube_; }
104
105protected:
106 QuantLib::ext::shared_ptr<SmileSection> smileSectionImpl(Time optionTime, Time swapLength) const override;
107
108 Volatility volatilityImpl(Time optionTime, Time swapLength, Rate strike) const override;
109
110private:
111 Handle<SwaptionVolatilityStructure> atm_, cube_;
112};
113
114} // namespace QuantExt
115
116#endif
const QuantLib::ext::shared_ptr< SmileSection > section_
const Handle< SwaptionVolatilityStructure > cube_
const Handle< SwaptionVolatilityStructure > atm_
Volatility volatilityImpl(Rate strike) const override
ConstantSpreadSmileSection(const Handle< SwaptionVolatilityStructure > &atm, const Handle< SwaptionVolatilityStructure > &cube, const Real optionTime, const Real swapLength)
Swaption cube that combines an ATM matrix and vol spreads from a cube.
Handle< SwaptionVolatilityStructure > cube_
const Handle< SwaptionVolatilityStructure > & cube()
Volatility volatilityImpl(Time optionTime, Time swapLength, Rate strike) const override
QuantLib::ext::shared_ptr< SmileSection > smileSectionImpl(Time optionTime, Time swapLength) const override
Handle< SwaptionVolatilityStructure > atm_
const Handle< SwaptionVolatilityStructure > & atmVol()
SwaptionVolatilityConstantSpread(const Handle< SwaptionVolatilityStructure > &atm, const Handle< SwaptionVolatilityStructure > &cube)