QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
sabrvolsurface.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2007 Ferdinando Ametrano
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy 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
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
24#ifndef quantlib_sabr_vol_surface_hpp
25#define quantlib_sabr_vol_surface_hpp
26
27#include <ql/experimental/volatility/interestratevolsurface.hpp>
28#include <ql/experimental/volatility/blackatmvolcurve.hpp>
29#include <ql/quote.hpp>
30#include <ql/termstructures/volatility/sabrinterpolatedsmilesection.hpp>
31#include <array>
32
33namespace QuantLib {
34
35
37
40 public:
41 SabrVolSurface(const ext::shared_ptr<InterestRateIndex>&,
43 const std::vector<Period>& optionTenors,
44 std::vector<Spread> atmRateSpreads,
45 std::vector<std::vector<Handle<Quote> > > volSpreads);
47 // All virtual methods of base classes must be forwarded
49
50 DayCounter dayCounter() const override;
51 Date maxDate() const override;
52 Time maxTime() const override;
53 const Date& referenceDate() const override;
54 Calendar calendar() const override;
55 Natural settlementDays() const override;
57
59 Real minStrike() const override;
60 Real maxStrike() const override;
64
65 void accept(AcyclicVisitor&) override;
67 std::vector<Volatility> volatilitySpreads(const Period&) const;
68 std::vector<Volatility> volatilitySpreads(const Date&) const;
69 protected:
70 std::array<Real, 4> sabrGuesses(const Date&) const;
71 public:
73
75 ext::shared_ptr<SmileSection> smileSectionImpl(Time) const override;
77 protected:
79
81 void performCalculations () const;
82 void update() override;
84 private:
86 void checkInputs() const;
87 void updateSabrGuesses(const Date& d, std::array<Real, 4> newGuesses) const;
89 std::vector<Period> optionTenors_;
90 std::vector<Time> optionTimes_;
91 std::vector<Date> optionDates_;
92 std::vector<Spread> atmRateSpreads_;
93 std::vector<std::vector<Handle<Quote> > > volSpreads_;
94 //
100 //
101 mutable std::vector<std::array<Real,4>> sabrGuesses_;
102 };
103
104 // inline
105
107 return atmCurve_->dayCounter();
108 }
109
111 return atmCurve_->maxDate();
112 }
113
115 return atmCurve_->maxTime();
116 }
117
118 inline const Date& SabrVolSurface::referenceDate() const {
119 return atmCurve_->referenceDate();
120 }
121
123 return atmCurve_->calendar();
124 }
125
127 return atmCurve_->settlementDays();
128 }
129
131 return QL_MIN_REAL;
132 }
133
135 return QL_MAX_REAL;
136 }
137
139 return atmCurve_;
140 }
141
142 inline std::vector<Volatility>
145 }
146}
147
148#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
calendar class
Definition: calendar.hpp:61
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) surface.
Date optionDateFromTenor(const Period &) const
period/date conversion
SABR volatility (smile) surface.
std::vector< Date > optionDates_
Handle< BlackAtmVolCurve > atmCurve_
Calendar calendar() const override
the calendar used for reference and/or option date calculation
void performCalculations() const
std::vector< std::array< Real, 4 > > sabrGuesses_
std::array< Real, 4 > sabrGuesses(const Date &) const
const Date & referenceDate() const override
the date at which discount = 1.0 and/or variance = 0.0
Real minStrike() const override
the minimum strike for which the term structure can return vols
void accept(AcyclicVisitor &) override
std::vector< Volatility > volatilitySpreads(const Period &) const
std::vector< Time > optionTimes_
Natural settlementDays() const override
the settlementDays used for reference date calculation
DayCounter dayCounter() const override
the day counter used for date/time conversion
std::vector< Spread > atmRateSpreads_
Date maxDate() const override
the latest date for which the curve can return values
std::vector< Period > optionTenors_
std::vector< std::vector< Handle< Quote > > > volSpreads_
const Handle< BlackAtmVolCurve > & atmCurve() const
Real maxStrike() const override
the maximum strike for which the term structure can return vols
Time maxTime() const override
the latest time for which the curve can return values
ext::shared_ptr< SmileSection > smileSectionImpl(Time) const override
void updateSabrGuesses(const Date &d, std::array< Real, 4 > newGuesses) const
#define QL_MAX_REAL
Definition: qldefines.hpp:176
#define QL_MIN_REAL
Definition: qldefines.hpp:175
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Definition: any.hpp:35