QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
tenorswaptionvts.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4Copyright (C) 2018 Sebastian Schlenkrich
5
6This file is part of QuantLib, a free-software/open-source library
7for financial quantitative analysts and developers - http://quantlib.org/
8
9QuantLib is free software: you can redistribute it and/or modify it
10under the terms of the QuantLib license. You should have received a
11copy of the license along with this program; if not, please email
12<quantlib-dev@lists.sf.net>. The license is also available online at
13<http://quantlib.org/license.shtml>.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file tenorswaptionvts.hpp
21 \brief swaption volatility term structure based on volatility transformation
22*/
23
24#ifndef quantlib_tenorswaptionvts_hpp
25#define quantlib_tenorswaptionvts_hpp
26
28#include <ql/option.hpp>
32#include <ql/time/date.hpp>
33#include <utility>
34
35namespace QuantLib {
36
38 protected:
40 protected:
41 ext::shared_ptr<SmileSection> baseSmileSection_;
47 // implement transformation formula
48 Volatility volatilityImpl(Rate strike) const override;
49
50 public:
51 // constructor includes actual transformation details
53 Time optionTime,
55
56 // further SmileSection interface methods
57 Real minStrike() const override {
58 return baseSmileSection_->minStrike() + swapRateTarg_ - swapRateBase_;
59 }
60 Real maxStrike() const override {
61 return baseSmileSection_->maxStrike() + swapRateTarg_ - swapRateBase_;
62 }
63 Real atmLevel() const override { return swapRateFinl_; }
64 };
65
68
69 ext::shared_ptr<IborIndex> baseIndex_;
70 ext::shared_ptr<IborIndex> targIndex_;
75
76 public:
77 // constructor
79 Handle<YieldTermStructure> discountCurve,
80 ext::shared_ptr<IborIndex> baseIndex,
81 ext::shared_ptr<IborIndex> targIndex,
82 const Period& baseFixedFreq,
83 const Period& targFixedFreq,
84 DayCounter baseFixedDC,
85 DayCounter targFixedDC)
87 baseVTS->calendar(),
88 baseVTS->businessDayConvention(),
89 baseVTS->dayCounter()),
90 baseVTS_(baseVTS), discountCurve_(std::move(discountCurve)),
91 baseIndex_(std::move(baseIndex)), targIndex_(std::move(targIndex)),
92 baseFixedFreq_(baseFixedFreq), targFixedFreq_(targFixedFreq),
93 baseFixedDC_(std::move(baseFixedDC)), targFixedDC_(std::move(targFixedDC)) {}
94
95 // Termstructure interface
96
97 //! the latest date for which the curve can return values
98 Date maxDate() const override { return baseVTS_->maxDate(); }
99
100 // SwaptionVolatility interface
101
102 //! the minimum strike for which the term structure can return vols
103 Rate minStrike() const override { return baseVTS_->minStrike(); }
104 //! the maximum strike for which the term structure can return vols
105 Rate maxStrike() const override { return baseVTS_->maxStrike(); }
106
107
108 // SwaptionVolatilityStructure interface
109
110 //! the largest length for which the term structure can return vols
111 const Period& maxSwapTenor() const override { return baseVTS_->maxSwapTenor(); }
112
113 ext::shared_ptr<SmileSection> smileSectionImpl(Time optionTime,
114 Time swapLength) const override {
115 return ext::shared_ptr<SmileSection>(
116 new TenorSwaptionSmileSection(*this, optionTime, swapLength));
117 }
118
119 Volatility volatilityImpl(Time optionTime, Time swapLength, Rate strike) const override {
120 return smileSectionImpl(optionTime, swapLength)->volatility(strike, Normal, 0.0);
121 }
122
123 // the methodology is designed for normal volatilities
124 VolatilityType volatilityType() const override { return Normal; }
125 };
126
127}
128
129#endif
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Shared handle to an observable.
Definition: handle.hpp:41
interest rate volatility smile section
Time swapLength(const Period &swapTenor) const
implements the conversion between swap tenor and swap (time) length
Volatility volatilityImpl(Rate strike) const override
Handle< YieldTermStructure > discountCurve_
Volatility volatilityImpl(Time optionTime, Time swapLength, Rate strike) const override
Rate maxStrike() const override
the maximum strike for which the term structure can return vols
Rate minStrike() const override
the minimum strike for which the term structure can return vols
Handle< SwaptionVolatilityStructure > baseVTS_
ext::shared_ptr< SmileSection > smileSectionImpl(Time optionTime, Time swapLength) const override
VolatilityType volatilityType() const override
volatility type
TenorSwaptionVTS(const Handle< SwaptionVolatilityStructure > &baseVTS, Handle< YieldTermStructure > discountCurve, ext::shared_ptr< IborIndex > baseIndex, ext::shared_ptr< IborIndex > targIndex, const Period &baseFixedFreq, const Period &targFixedFreq, DayCounter baseFixedDC, DayCounter targFixedDC)
ext::shared_ptr< IborIndex > targIndex_
Date maxDate() const override
the latest date for which the curve can return values
const Period & maxSwapTenor() const override
the largest length for which the term structure can return vols
ext::shared_ptr< IborIndex > baseIndex_
virtual const Date & referenceDate() const
the date at which discount = 1.0 and/or variance = 0.0
virtual Calendar calendar() const
the calendar used for reference and/or option date calculation
virtual DayCounter dayCounter() const
the day counter used for date/time conversion
virtual BusinessDayConvention businessDayConvention() const
the business day convention used in tenor to date conversion
date- and time-related classes, typedefs and enumerations
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Real Volatility
volatility
Definition: types.hpp:78
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35
STL namespace.
Base option class.
Smile section base class.
Swaption class.
Swaption volatility structure.
Interest-rate term structure.