Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
swaptionvolatilityconverter.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 qle/termstructures/swaptionvolatilityconverter.hpp
20 \brief Convert swaption volatilities from one type to another
21 \ingroup termstructures
22*/
23
24#ifndef quantext_swaptionvolatilityconverter_hpp
25#define quantext_swaptionvolatilityconverter_hpp
26
27#include <ql/indexes/iborindex.hpp>
28#include <ql/indexes/swapindex.hpp>
29#include <ql/termstructures/volatility/swaption/swaptionvolmatrix.hpp>
30
31#include <ql/shared_ptr.hpp>
32
33namespace QuantExt {
34using namespace QuantLib;
35using std::vector;
36
37//! Container for holding swap conventions needed by the SwaptionVolatilityConverter
38//! \ingroup termstructures
40public:
41 //! Constructor
42 SwapConventions(Natural settlementDays, const Period& fixedTenor, const Calendar& fixedCalendar,
43 BusinessDayConvention fixedConvention, const DayCounter& fixedDayCounter,
44 const QuantLib::ext::shared_ptr<IborIndex>& floatIndex)
47
48 //! \name Inspectors
49 //@{
50 Natural settlementDays() const { return settlementDays_; }
51 const Period& fixedTenor() const { return fixedTenor_; }
52 const Calendar& fixedCalendar() const { return fixedCalendar_; }
53 BusinessDayConvention fixedConvention() const { return fixedConvention_; }
54 const DayCounter& fixedDayCounter() const { return fixedDayCounter_; }
55 const QuantLib::ext::shared_ptr<IborIndex> floatIndex() const { return floatIndex_; }
56 //@}
57
58private:
62 BusinessDayConvention fixedConvention_;
63 DayCounter fixedDayCounter_;
64 QuantLib::ext::shared_ptr<IborIndex> floatIndex_;
65};
66
67//! Class that converts a supplied SwaptionVolatilityStructure to one of another type with possibly different shifts
68/*! \ingroup termstructures
69
70 \warning the converted <tt>SwaptionVolatilityStructure</tt> object has a fixed reference date equal to
71 <tt>asof</tt> and fixed market data regardless of the type of reference date and market data of the
72 original <tt>SwaptionVolatilityStructure</tt> that is passed in
73*/
75public:
76 //! Construct from SwapConventions
77 SwaptionVolatilityConverter(const Date& asof, const QuantLib::ext::shared_ptr<SwaptionVolatilityStructure>& svsIn,
78 const Handle<YieldTermStructure>& discount,
79 const Handle<YieldTermStructure>& shortDiscount,
80 const QuantLib::ext::shared_ptr<SwapConventions>& conventions,
81 const QuantLib::ext::shared_ptr<SwapConventions>& shortConventions,
82 const Period& conventionsTenor, const Period& shortConventionsTenor,
83 const VolatilityType targetType, const Matrix& targetShifts = Matrix());
84 //! Construct from SwapIndex
85 SwaptionVolatilityConverter(const Date& asof, const QuantLib::ext::shared_ptr<SwaptionVolatilityStructure>& svsIn,
86 const QuantLib::ext::shared_ptr<SwapIndex>& swapIndex,
87 const QuantLib::ext::shared_ptr<SwapIndex>& shortSwapIndex, const VolatilityType targetType,
88 const Matrix& targetShifts = Matrix());
89
90 //! Method that returns the converted <tt>SwaptionVolatilityStructure</tt>
91 QuantLib::ext::shared_ptr<SwaptionVolatilityStructure> convert() const;
92
93 // Convert a single vol associated with a given swaption
94 Real convert(const Date& expiry, const Period& swapTenor, Real strikeSpread, const DayCounter& volDayCounter,
95 VolatilityType outType, Real outShift = 0.0) const;
96
97 //! Set implied volatility solver accuracy
98 Real& accuracy() { return accuracy_; }
99 //! Set implied volatility solver max evaluations
100 Natural& maxEvaluations() { return maxEvaluations_; }
101
102private:
103 // Check inputs
104 void checkInputs() const;
105
106 // Method that is called depending on the type of svsIn
107 QuantLib::ext::shared_ptr<SwaptionVolatilityStructure>
108 convert(const QuantLib::ext::shared_ptr<SwaptionVolatilityMatrix>& svMatrix) const;
109
110 const Date asof_;
111 const QuantLib::ext::shared_ptr<SwaptionVolatilityStructure> svsIn_;
112 Handle<YieldTermStructure> discount_, shortDiscount_;
113 const QuantLib::ext::shared_ptr<SwapConventions> conventions_, shortConventions_;
115 const VolatilityType targetType_;
116 const Matrix targetShifts_;
117
118 // Variables for implied volatility solver
121 static const Volatility minVol_;
122 static const Volatility maxVol_;
123 static const Real minVega_;
124};
125} // namespace QuantExt
126
127#endif
QuantLib::ext::shared_ptr< IborIndex > floatIndex_
const QuantLib::ext::shared_ptr< IborIndex > floatIndex() const
const DayCounter & fixedDayCounter() const
SwapConventions(Natural settlementDays, const Period &fixedTenor, const Calendar &fixedCalendar, BusinessDayConvention fixedConvention, const DayCounter &fixedDayCounter, const QuantLib::ext::shared_ptr< IborIndex > &floatIndex)
Constructor.
BusinessDayConvention fixedConvention() const
const Calendar & fixedCalendar() const
Class that converts a supplied SwaptionVolatilityStructure to one of another type with possibly diffe...
Real & accuracy()
Set implied volatility solver accuracy.
QuantLib::ext::shared_ptr< SwaptionVolatilityStructure > convert(const QuantLib::ext::shared_ptr< SwaptionVolatilityMatrix > &svMatrix) const
const QuantLib::ext::shared_ptr< SwapConventions > conventions_
QuantLib::ext::shared_ptr< SwaptionVolatilityStructure > convert() const
Method that returns the converted SwaptionVolatilityStructure
Natural & maxEvaluations()
Set implied volatility solver max evaluations.
const QuantLib::ext::shared_ptr< SwaptionVolatilityStructure > svsIn_
const QuantLib::ext::shared_ptr< SwapConventions > shortConventions_