QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
sabrinterpolatedsmilesection.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2007 Cristina Duminuco
5 Copyright (C) 2006 François du Vignaud
6 Copyright (C) 2015 Peter Caspers
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
22/*! \file sabrinterpolatedsmilesection.hpp
23 \brief Interpolated smile section class
24*/
25
26#ifndef quantlib_sabr_interpolated_smile_section_hpp
27#define quantlib_sabr_interpolated_smile_section_hpp
28
29#include <ql/handle.hpp>
34
35namespace QuantLib {
36
37 class Quote;
39 public LazyObject {
40 public:
41 //! \name Constructors
42 //@{
43 //! all market data are quotes
45 const Date& optionDate,
46 Handle<Quote> forward,
47 const std::vector<Rate>& strikes,
48 bool hasFloatingStrikes,
49 Handle<Quote> atmVolatility,
50 const std::vector<Handle<Quote> >& volHandles,
51 Real alpha,
52 Real beta,
53 Real nu,
54 Real rho,
55 bool isAlphaFixed = false,
56 bool isBetaFixed = false,
57 bool isNuFixed = false,
58 bool isRhoFixed = false,
59 bool vegaWeighted = true,
60 ext::shared_ptr<EndCriteria> endCriteria = ext::shared_ptr<EndCriteria>(),
61 ext::shared_ptr<OptimizationMethod> method = ext::shared_ptr<OptimizationMethod>(),
62 const DayCounter& dc = Actual365Fixed(),
63 Real shift = 0.0);
64 //! no quotes
66 const Date& optionDate,
67 const Rate& forward,
68 const std::vector<Rate>& strikes,
69 bool hasFloatingStrikes,
70 const Volatility& atmVolatility,
71 const std::vector<Volatility>& vols,
72 Real alpha,
73 Real beta,
74 Real nu,
75 Real rho,
76 bool isAlphaFixed = false,
77 bool isBetaFixed = false,
78 bool isNuFixed = false,
79 bool isRhoFixed = false,
80 bool vegaWeighted = true,
81 ext::shared_ptr<EndCriteria> endCriteria = ext::shared_ptr<EndCriteria>(),
82 ext::shared_ptr<OptimizationMethod> method = ext::shared_ptr<OptimizationMethod>(),
83 const DayCounter& dc = Actual365Fixed(),
84 Real shift = 0.0);
85 //@}
86 //! \name LazyObject interface
87 //@{
88 void performCalculations() const override;
89 void update() override;
90 //@}
91 //! \name SmileSection interface
92 //@{
93 Real minStrike() const override;
94 Real maxStrike() const override;
95 Real atmLevel() const override;
96 //@}
97 Real varianceImpl(Rate strike) const override;
98 Volatility volatilityImpl(Rate strike) const override;
99 //! \name Inspectors
100 //@{
101 Real alpha() const;
102 Real beta() const;
103 Real nu() const;
104 Real rho() const;
105 Real rmsError() const;
106 Real maxError() const;
108 //@}
109
110 protected:
111
112 //! Creates the mutable SABRInterpolation
113 void createInterpolation() const;
114 mutable ext::shared_ptr<SABRInterpolation> sabrInterpolation_;
115
116 //! Market data
119 std::vector<Handle<Quote> > volHandles_;
120 mutable std::vector<Rate> strikes_;
121 //! Only strikes corresponding to valid market data
122 mutable std::vector<Rate> actualStrikes_;
124
126 mutable std::vector<Volatility> vols_;
127 //! Sabr parameters
129 //! Sabr interpolation settings
132 const ext::shared_ptr<EndCriteria> endCriteria_;
133 const ext::shared_ptr<OptimizationMethod> method_;
134
136 };
137
141 }
142
144 calculate();
145 return (*sabrInterpolation_)(strike, true);
146 }
147
149 calculate();
150 return sabrInterpolation_->alpha();
151 }
152
154 calculate();
155 return sabrInterpolation_->beta();
156 }
157
159 calculate();
160 return sabrInterpolation_->nu();
161 }
162
164 calculate();
165 return sabrInterpolation_->rho();
166 }
167
169 calculate();
170 return sabrInterpolation_->rmsError();
171 }
172
174 calculate();
175 return sabrInterpolation_->maxError();
176 }
177
179 calculate();
180 return sabrInterpolation_->endCriteria();
181 }
182
184 calculate();
185 return actualStrikes_.front();
186
187 }
188
190 calculate();
191 return actualStrikes_.back();
192 }
193
195 calculate();
196 return forwardValue_;
197 }
198
199
200}
201
202#endif
Actual/365 (Fixed) day counter.
Actual/365 (Fixed) day count convention.
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Shared handle to an observable.
Definition: handle.hpp:41
Framework for calculation on demand and result caching.
Definition: lazyobject.hpp:35
virtual void calculate() const
Definition: lazyobject.hpp:253
void update() override
Definition: lazyobject.hpp:188
const ext::shared_ptr< EndCriteria > endCriteria_
ext::shared_ptr< SABRInterpolation > sabrInterpolation_
void createInterpolation() const
Creates the mutable SABRInterpolation.
std::vector< Rate > actualStrikes_
Only strikes corresponding to valid market data.
const ext::shared_ptr< OptimizationMethod > method_
Volatility volatilityImpl(Rate strike) const override
interest rate volatility smile section
void update() override
virtual Rate shift() const
QL_REAL Real
real number
Definition: types.hpp:50
Real Volatility
volatility
Definition: types.hpp:78
Real Rate
interest rates
Definition: types.hpp:70
Globally accessible relinkable pointer.
framework for calculation on demand and result caching
Definition: any.hpp:35
SABR interpolation interpolation between discrete points.
Smile section base class.