QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
constantoptionletvol.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) 2004, 2005, 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/optionlet/constantoptionletvol.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 VolatilityType type,
36 Real displacement)
37 : OptionletVolatilityStructure(settlementDays, cal, bdc, dc), volatility_(std::move(vol)),
38 type_(type), displacement_(displacement) {
40 }
41
42 // fixed reference date, floating market data
44 const Calendar& cal,
46 Handle<Quote> vol,
47 const DayCounter& dc,
48 VolatilityType type,
49 Real displacement)
50 : OptionletVolatilityStructure(referenceDate, cal, bdc, dc), volatility_(std::move(vol)),
51 type_(type), displacement_(displacement) {
53 }
54
55 // floating reference date, fixed market data
57 Natural settlementDays, const Calendar &cal, BusinessDayConvention bdc,
58 Volatility vol, const DayCounter &dc, VolatilityType type,
59 Real displacement)
60 : OptionletVolatilityStructure(settlementDays, cal, bdc, dc),
61 volatility_(ext::shared_ptr< Quote >(new SimpleQuote(vol))),
62 type_(type), displacement_(displacement) {}
63
64 // fixed reference date, fixed market data
66 const Date &referenceDate, const Calendar &cal,
68 VolatilityType type, Real displacement)
69 : OptionletVolatilityStructure(referenceDate, cal, bdc, dc),
70 volatility_(ext::shared_ptr< Quote >(new SimpleQuote(vol))),
71 type_(type), displacement_(displacement) {}
72
73 ext::shared_ptr<SmileSection>
75 Volatility atmVol = volatility_->value();
76 return ext::shared_ptr<SmileSection>(new
78 }
79
80 ext::shared_ptr<SmileSection>
82 Volatility atmVol = volatility_->value();
83 return ext::shared_ptr<SmileSection>(new
84 FlatSmileSection(optionTime, atmVol, dayCounter()));
85 }
86
88 Rate) const {
89 return volatility_->value();
90 }
91
92}
calendar class
Definition: calendar.hpp:61
Volatility volatilityImpl(Time, Rate) const override
implements the actual volatility calculation in derived classes
ConstantOptionletVolatility(Natural settlementDays, const Calendar &cal, BusinessDayConvention bdc, Handle< Quote > volatility, const DayCounter &dc, VolatilityType type=ShiftedLognormal, Real displacement=0.0)
floating reference date, floating market data
ext::shared_ptr< SmileSection > smileSectionImpl(const Date &d) 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
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
Optionlet (caplet/floorlet) volatility structure.
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.