QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
swaptionconstantvol.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 Ferdinando Ametrano
5 Copyright (C) 2006, 2007 StatPro Italia srl
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#include <ql/quotes/simplequote.hpp>
23#include <ql/termstructures/volatility/flatsmilesection.hpp>
24#include <ql/termstructures/volatility/swaption/swaptionconstantvol.hpp>
25#include <utility>
26
27namespace QuantLib {
28
29 // floating reference date, floating market data
31 const Calendar& cal,
33 Handle<Quote> vol,
34 const DayCounter& dc,
35 const VolatilityType type,
36 const Real shift)
37 : SwaptionVolatilityStructure(settlementDays, cal, bdc, dc), volatility_(std::move(vol)),
38 maxSwapTenor_(100 * Years), volatilityType_(type), shift_(shift) {
40 }
41
42 // fixed reference date, floating market data
44 const Calendar& cal,
46 Handle<Quote> vol,
47 const DayCounter& dc,
48 const VolatilityType type,
49 const Real shift)
50 : SwaptionVolatilityStructure(referenceDate, cal, bdc, dc), volatility_(std::move(vol)),
51 maxSwapTenor_(100 * Years), volatilityType_(type), shift_(shift) {
53 }
54
55 // floating reference date, fixed market data
57 Natural settlementDays,
58 const Calendar& cal,
60 Volatility vol,
61 const DayCounter& dc,
62 const VolatilityType type,
63 const Real shift)
64 : SwaptionVolatilityStructure(settlementDays, cal, bdc, dc),
65 volatility_(ext::shared_ptr<Quote>(new SimpleQuote(vol))),
66 maxSwapTenor_(100*Years), volatilityType_(type), shift_(shift) {}
67
68 // fixed reference date, fixed market data
70 const Date& referenceDate,
71 const Calendar& cal,
73 Volatility vol,
74 const DayCounter& dc,
75 const VolatilityType type,
76 const Real shift)
77 : SwaptionVolatilityStructure(referenceDate, cal, bdc, dc),
78 volatility_(ext::shared_ptr<Quote>(new SimpleQuote(vol))),
79 maxSwapTenor_(100*Years), volatilityType_(type), shift_(shift) {}
80
81 ext::shared_ptr<SmileSection>
83 const Period&) const {
84 Volatility atmVol = volatility_->value();
85 return ext::shared_ptr<SmileSection>(
86 new FlatSmileSection(d, atmVol, dayCounter(), referenceDate(),
88 }
89
90 ext::shared_ptr<SmileSection>
92 Time) const {
93 Volatility atmVol = volatility_->value();
94 return ext::shared_ptr<SmileSection>(
95 new FlatSmileSection(optionTime, atmVol, dayCounter(), Null<Rate>(),
97 }
98
100 const Period&,
101 Rate) const {
102 return volatility_->value();
103 }
104
106 Time,
107 Rate) const {
108 return volatility_->value();
109 }
110
111}
calendar class
Definition: calendar.hpp:61
ConstantSwaptionVolatility(Natural settlementDays, const Calendar &cal, BusinessDayConvention bdc, Handle< Quote > volatility, const DayCounter &dc, VolatilityType type=ShiftedLognormal, Real shift=0.0)
floating reference date, floating market data
ext::shared_ptr< SmileSection > smileSectionImpl(const Date &, const Period &) const override
Volatility volatilityImpl(const Date &, const Period &, Rate) const override
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Shared handle to an observable.
Definition: handle.hpp:41
template class providing a null value for a given type.
Definition: null.hpp:76
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
purely virtual base class for market observables
Definition: quote.hpp:37
market element returning a stored value
Definition: simplequote.hpp:33
virtual const Date & referenceDate() const
the date at which discount = 1.0 and/or variance = 0.0
virtual DayCounter dayCounter() const
the day counter used for date/time 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
Definition: any.hpp:35
STL namespace.