QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
swaptionvoldiscrete.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) 2006 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
20/*! \file swaptionvoldiscrete.hpp
21 \brief Discretized swaption volatility
22*/
23
24#ifndef quantlib_swaption_volatility_discrete_h
25#define quantlib_swaption_volatility_discrete_h
26
30
31namespace QuantLib {
32
35 public:
36 SwaptionVolatilityDiscrete(const std::vector<Period>& optionTenors,
37 const std::vector<Period>& swapTenors,
39 const Calendar& cal,
41 const DayCounter& dc);
42 SwaptionVolatilityDiscrete(const std::vector<Period>& optionTenors,
43 const std::vector<Period>& swapTenors,
44 const Date& referenceDate,
45 const Calendar& cal,
47 const DayCounter& dc);
48 SwaptionVolatilityDiscrete(const std::vector<Date>& optionDates,
49 const std::vector<Period>& swapTenors,
50 const Date& referenceDate,
51 const Calendar& cal,
53 const DayCounter& dc);
54 const std::vector<Period>& optionTenors() const;
55 const std::vector<Date>& optionDates() const;
56 const std::vector<Time>& optionTimes() const;
57 const std::vector<Period>& swapTenors() const;
58 const std::vector<Time>& swapLengths() const;
59 //@}
60 //! \name Observer interface
61 //@{
62 void update() override;
63 //@}
64 //! \name LazyObject interface
65 //@{
66 void performCalculations() const override;
67 //@}
68 //! additional inspectors
69 Date optionDateFromTime(Time optionTime) const;
70
71 protected:
73 std::vector<Period> optionTenors_;
74 mutable std::vector<Date> optionDates_;
75 mutable std::vector<Time> optionTimes_;
77 mutable std::vector<Real> optionDatesAsReal_;
78 mutable std::vector<Time> optionInterpolatorTimes_;
79 mutable std::vector<Real> optionInterpolatorDatesAsReal_;
80
82 std::vector<Period> swapTenors_;
83 mutable std::vector<Time> swapLengths_;
85 private:
86 void checkOptionTenors() const;
87 void checkOptionDates(const Date& reference) const;
88 void checkSwapTenors() const;
90 void initializeOptionTimes() const;
91 void initializeSwapLengths() const;
92 };
93
94 // inline
95
96 inline const std::vector<Period>&
98 return optionTenors_;
99 }
100
101 inline const std::vector<Date>&
103 return optionDates_;
104 }
105
106 inline const std::vector<Time>&
108 return optionTimes_;
109 }
110
111 inline const std::vector<Period>&
113 return swapTenors_;
114 }
115
116 inline const std::vector<Time>&
118 return swapLengths_;
119 }
120
122 return Date(static_cast<Date::serial_type>(optionInterpolator_(optionTime)));
123 }
124}
125
126#endif
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
std::int_fast32_t serial_type
serial number type
Definition: date.hpp:128
day counter class
Definition: daycounter.hpp:44
base class for 1-D interpolations.
Framework for calculation on demand and result caching.
Definition: lazyobject.hpp:35
const std::vector< Time > & swapLengths() const
const std::vector< Period > & swapTenors() const
const std::vector< Period > & optionTenors() const
const std::vector< Time > & optionTimes() const
const std::vector< Date > & optionDates() const
void checkOptionDates(const Date &reference) const
Date optionDateFromTime(Time optionTime) const
additional inspectors
virtual Natural settlementDays() const
the settlementDays used for reference date calculation
virtual const Date & referenceDate() const
the date at which discount = 1.0 and/or variance = 0.0
BusinessDayConvention
Business Day conventions.
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
std::size_t Size
size of a container
Definition: types.hpp:58
base class for 1-D interpolations
framework for calculation on demand and result caching
Definition: any.hpp:35
Swaption volatility structure.