QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
capfloortermvolcurve.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 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
7 Copyright (C) 2003, 2004, 2005 StatPro Italia srl
8
9 This file is part of QuantLib, a free-software/open-source library
10 for financial quantitative analysts and developers - http://quantlib.org/
11
12 QuantLib is free software: you can redistribute it and/or modify it
13 under the terms of the QuantLib license. You should have received a
14 copy of the license along with this program; if not, please email
15 <quantlib-dev@lists.sf.net>. The license is also available online at
16 <http://quantlib.org/license.shtml>.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the license for more details.
21*/
22
27#ifndef quantlib_cap_volatility_vector_hpp
28#define quantlib_cap_volatility_vector_hpp
29
30#include <ql/termstructures/volatility/capfloor/capfloortermvolatilitystructure.hpp>
31#include <ql/math/interpolation.hpp>
32#include <ql/quote.hpp>
33#include <ql/patterns/lazyobject.hpp>
34#include <ql/time/daycounters/actual365fixed.hpp>
35#include <vector>
36
37namespace QuantLib {
38
40
46 public:
49 const Calendar& calendar,
51 const std::vector<Period>& optionTenors,
52 const std::vector<Handle<Quote> >& vols,
53 const DayCounter& dc = Actual365Fixed());
55 CapFloorTermVolCurve(const Date& settlementDate,
56 const Calendar& calendar,
58 const std::vector<Period>& optionTenors,
59 const std::vector<Handle<Quote> >& vols,
60 const DayCounter& dc = Actual365Fixed());
62 CapFloorTermVolCurve(const Date& settlementDate,
63 const Calendar& calendar,
65 const std::vector<Period>& optionTenors,
66 const std::vector<Volatility>& vols,
67 const DayCounter& dc = Actual365Fixed());
70 const Calendar& calendar,
72 const std::vector<Period>& optionTenors,
73 const std::vector<Volatility>& vols,
74 const DayCounter& dc = Actual365Fixed());
75
76 // make class non-copyable and non-movable
81
82 ~CapFloorTermVolCurve() override = default;
83
85
86 Date maxDate() const override;
88
90 Real minStrike() const override;
91 Real maxStrike() const override;
93
95 void update() override;
96 void performCalculations() const override;
98
100 const std::vector<Period>& optionTenors() const;
101 const std::vector<Date>& optionDates() const;
102 const std::vector<Time>& optionTimes() const;
104 protected:
105 Volatility volatilityImpl(Time length, Rate) const override;
106
107 private:
108 void checkInputs() const;
111 void interpolate();
112
114 std::vector<Period> optionTenors_;
115 mutable std::vector<Date> optionDates_;
116 mutable std::vector<Time> optionTimes_;
118
119 std::vector<Handle<Quote> > volHandles_;
120 mutable std::vector<Volatility> vols_;
121
122 // make it not mutable if possible
124 };
125
126 // inline definitions
127
129 calculate();
130 return optionDateFromTenor(optionTenors_.back());
131 }
132
134 return QL_MIN_REAL;
135 }
136
138 return QL_MAX_REAL;
139 }
140
141 inline
143 Rate) const {
144 calculate();
145 return interpolation_(t, true);
146 }
147
148 inline
149 const std::vector<Period>& CapFloorTermVolCurve::optionTenors() const {
150 return optionTenors_;
151 }
152
153 inline
154 const std::vector<Date>& CapFloorTermVolCurve::optionDates() const {
155 // what if quotes are not available?
156 calculate();
157 return optionDates_;
158 }
159
160 inline
161 const std::vector<Time>& CapFloorTermVolCurve::optionTimes() const {
162 // what if quotes are not available?
163 calculate();
164 return optionTimes_;
165 }
166
167}
168
169#endif
Actual/365 (Fixed) day count convention.
calendar class
Definition: calendar.hpp:61
Cap/floor at-the-money term-volatility vector.
CapFloorTermVolCurve(const CapFloorTermVolCurve &)=delete
void performCalculations() const override
CapFloorTermVolCurve & operator=(CapFloorTermVolCurve &&)=delete
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
Date maxDate() const override
the latest date for which the curve can return values
const std::vector< Date > & optionDates() const
CapFloorTermVolCurve & operator=(const CapFloorTermVolCurve &)=delete
CapFloorTermVolCurve(CapFloorTermVolCurve &&)=delete
Real maxStrike() const override
the maximum strike for which the term structure can return vols
std::vector< Handle< Quote > > volHandles_
Volatility volatilityImpl(Time length, Rate) const override
implements the actual volatility calculation in derived classes
~CapFloorTermVolCurve() override=default
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 1-D interpolations.
Framework for calculation on demand and result caching.
Definition: lazyobject.hpp:35
virtual void calculate() const
Definition: lazyobject.hpp:253
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.
#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
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