QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
capfloortermvolsurface.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2007 Ferdinando Ametrano
5 Copyright (C) 2007 Katiuscia Manzoni
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
25#ifndef quantlib_cap_floor_term_vol_surface_hpp
26#define quantlib_cap_floor_term_vol_surface_hpp
27
28#include <ql/termstructures/volatility/capfloor/capfloortermvolatilitystructure.hpp>
29#include <ql/math/interpolations/interpolation2d.hpp>
30#include <ql/quote.hpp>
31#include <ql/patterns/lazyobject.hpp>
32#include <ql/time/daycounters/actual365fixed.hpp>
33#include <vector>
34
35namespace QuantLib {
36
38
44 public:
47 const Calendar& calendar,
49 const std::vector<Period>& optionTenors,
50 const std::vector<Rate>& strikes,
51 const std::vector<std::vector<Handle<Quote> > >&,
52 const DayCounter& dc = Actual365Fixed());
54 CapFloorTermVolSurface(const Date& settlementDate,
55 const Calendar& calendar,
57 const std::vector<Period>& optionTenors,
58 const std::vector<Rate>& strikes,
59 const std::vector<std::vector<Handle<Quote> > >&,
60 const DayCounter& dc = Actual365Fixed());
62 CapFloorTermVolSurface(const Date& settlementDate,
63 const Calendar& calendar,
65 const std::vector<Period>& optionTenors,
66 const std::vector<Rate>& strikes,
67 const Matrix& volatilities,
68 const DayCounter& dc = Actual365Fixed());
71 const Calendar& calendar,
73 const std::vector<Period>& optionTenors,
74 const std::vector<Rate>& strikes,
75 const Matrix& volatilities,
76 const DayCounter& dc = Actual365Fixed());
78
79 Date maxDate() const override;
81
83 Real minStrike() const override;
84 Real maxStrike() const override;
86
88 void update() override;
89 void performCalculations() const override;
91
93 const std::vector<Period>& optionTenors() const;
94 const std::vector<Date>& optionDates() const;
95 const std::vector<Time>& optionTimes() const;
96 const std::vector<Rate>& strikes() const;
98 protected:
99 Volatility volatilityImpl(Time t, Rate strike) const override;
100
101 private:
102 void checkInputs() const;
105 void interpolate();
106
108 std::vector<Period> optionTenors_;
109 mutable std::vector<Date> optionDates_;
110 mutable std::vector<Time> optionTimes_;
112
114 std::vector<Rate> strikes_;
115
116 std::vector<std::vector<Handle<Quote> > > volHandles_;
117 mutable Matrix vols_;
118
119 // make it not mutable if possible
121 };
122
123 // inline definitions
124
126 calculate();
127 return optionDateFromTenor(optionTenors_.back());
128 }
129
131 return strikes_.front();
132 }
133
135 return strikes_.back();
136 }
137
138 inline
140 Rate strike) const {
141 calculate();
142 return interpolation_(strike, t, true);
143 }
144
145 inline
146 const std::vector<Period>& CapFloorTermVolSurface::optionTenors() const {
147 return optionTenors_;
148 }
149
150 inline
151 const std::vector<Date>& CapFloorTermVolSurface::optionDates() const {
152 // what if quotes are not available?
153 calculate();
154 return optionDates_;
155 }
156
157 inline
158 const std::vector<Time>& CapFloorTermVolSurface::optionTimes() const {
159 // what if quotes are not available?
160 calculate();
161 return optionTimes_;
162 }
163
164 inline const std::vector<Rate>& CapFloorTermVolSurface::strikes() const {
165 return strikes_;
166 }
167}
168
169#endif
Actual/365 (Fixed) day count convention.
calendar class
Definition: calendar.hpp:61
Cap/floor smile volatility surface.
std::vector< std::vector< Handle< Quote > > > volHandles_
Real minStrike() const override
the minimum strike for which the term structure can return vols
const std::vector< Period > & optionTenors() const
const std::vector< Time > & optionTimes() const
const std::vector< Rate > & strikes() const
Date maxDate() const override
the latest date for which the curve can return values
const std::vector< Date > & optionDates() const
Volatility volatilityImpl(Time t, Rate strike) const override
implements the actual volatility calculation in derived classes
Real maxStrike() const override
the maximum strike for which the term structure can return vols
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Shared handle to an observable.
Definition: handle.hpp:41
base class for 2-D interpolations.
Framework for calculation on demand and result caching.
Definition: lazyobject.hpp:35
virtual void calculate() const
Definition: lazyobject.hpp:253
Matrix used in linear algebra.
Definition: matrix.hpp:41
virtual Natural settlementDays() const
the settlementDays used for reference date calculation
virtual Calendar calendar() const
the calendar used for reference and/or option date calculation
Date optionDateFromTenor(const Period &) const
period/date conversion
BusinessDayConvention
Business Day conventions.
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
Real Volatility
volatility
Definition: types.hpp:78
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35