QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
tenoroptionletvts.hpp
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
24#ifndef quantlib_tenoroptionletvts_hpp
25#define quantlib_tenoroptionletvts_hpp
26
27#include <ql/indexes/iborindex.hpp>
28#include <ql/math/interpolation.hpp>
29#include <ql/termstructures/volatility/optionlet/optionletvolatilitystructure.hpp>
30#include <ql/termstructures/volatility/smilesection.hpp>
31#include <ql/time/dategenerationrule.hpp>
32#include <utility>
33
34
35namespace QuantLib {
36
38
39 public:
40 class CorrelationStructure; // declaration below
41
42 protected:
44 protected:
45 ext::shared_ptr<CorrelationStructure> correlation_;
46 std::vector<ext::shared_ptr<SmileSection> > baseSmileSection_;
47 std::vector<Time> startTimeBase_; // for correlation parametrisation
48 std::vector<Real> fraRateBase_;
50 std::vector<Real> v_;
51 // implement transformation formula
52 Volatility volatilityImpl(Rate strike) const override;
53
54 public:
55 // constructor includes actual transformation details
56 TenorOptionletSmileSection(const TenorOptionletVTS& volTS, Time optionTime);
57
58 // further SmileSection interface methods
59 Real minStrike() const override {
60 return baseSmileSection_[0]->minStrike() + fraRateTarg_ - fraRateBase_[0];
61 }
62 Real maxStrike() const override {
63 return baseSmileSection_[0]->maxStrike() + fraRateTarg_ - fraRateBase_[0];
64 }
65 Real atmLevel() const override { return fraRateTarg_; }
66 };
67
69 ext::shared_ptr<IborIndex> baseIndex_;
70 ext::shared_ptr<IborIndex> targIndex_;
71 ext::shared_ptr<CorrelationStructure> correlation_;
72
73 public:
74 // functor interface for parametric correlation
76 public:
77 // return the correlation between two FRA rates starting at start1 and start2
78 virtual Real operator()(const Time& start1, const Time& start2) const = 0;
79 virtual ~CorrelationStructure() = default;
80 ;
81 };
82
83 // very basic choice for correlation structure
85 protected:
86 ext::shared_ptr<Interpolation> rhoInf_;
87 ext::shared_ptr<Interpolation> beta_;
88
89 public:
90 TwoParameterCorrelation(ext::shared_ptr<Interpolation> rhoInf,
91 ext::shared_ptr<Interpolation> beta)
92 : rhoInf_(std::move(rhoInf)), beta_(std::move(beta)) {}
93 Real operator()(const Time& start1, const Time& start2) const override {
94 Real rhoInf = (*rhoInf_)(start1);
95 Real beta = (*beta_)(start1);
96 Real rho = rhoInf + (1.0 - rhoInf) * exp(-beta * fabs(start2 - start1));
97 return rho;
98 }
99 };
100
101 // constructor
103 ext::shared_ptr<IborIndex> baseIndex,
104 ext::shared_ptr<IborIndex> targIndex,
105 ext::shared_ptr<CorrelationStructure> correlation);
106
107 // Termstructure interface
108
110 Date maxDate() const override { return baseVTS_->maxDate(); }
111
112 // VolatilityTermstructure interface
113
115 ext::shared_ptr<SmileSection> smileSectionImpl(Time optionTime) const override {
116 return ext::shared_ptr<SmileSection>(new TenorOptionletSmileSection(*this, optionTime));
117 }
119 Volatility volatilityImpl(Time optionTime, Rate strike) const override {
120 return smileSection(optionTime)->volatility(strike);
121 }
122
123
125 Rate minStrike() const override { return baseVTS_->minStrike(); }
127 Rate maxStrike() const override { return baseVTS_->maxStrike(); }
128
129 // the methodology is designed for normal volatilities
130 VolatilityType volatilityType() const override { return Normal; }
131 };
132
134
135}
136
137#endif
Concrete date class.
Definition: date.hpp:125
Shared handle to an observable.
Definition: handle.hpp:41
Optionlet (caplet/floorlet) volatility structure.
ext::shared_ptr< SmileSection > smileSection(const Period &optionTenor, bool extr=false) const
returns the smile for a given option tenor
interest rate volatility smile section
virtual Real operator()(const Time &start1, const Time &start2) const =0
ext::shared_ptr< CorrelationStructure > correlation_
std::vector< ext::shared_ptr< SmileSection > > baseSmileSection_
Volatility volatilityImpl(Rate strike) const override
TwoParameterCorrelation(ext::shared_ptr< Interpolation > rhoInf, ext::shared_ptr< Interpolation > beta)
Real operator()(const Time &start1, const Time &start2) 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
ext::shared_ptr< SmileSection > smileSectionImpl(Time optionTime) const override
implements the actual smile calculation in derived classes
Volatility volatilityImpl(Time optionTime, Rate strike) const override
implements the actual volatility calculation in derived classes
ext::shared_ptr< CorrelationStructure > correlation_
VolatilityType volatilityType() const override
ext::shared_ptr< IborIndex > targIndex_
Date maxDate() const override
the latest date for which the curve can return values
Handle< OptionletVolatilityStructure > baseVTS_
ext::shared_ptr< IborIndex > baseIndex_
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
TenorOptionletVTS::CorrelationStructure TenorOptionletVTSCorrelationStructure
STL namespace.