QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
spreadedoptionletvol.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) 2007 Giorgio Facchinetti
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
21#include <ql/quote.hpp>
22#include <ql/termstructures/volatility/optionlet/spreadedoptionletvol.hpp>
23#include <ql/termstructures/volatility/spreadedsmilesection.hpp>
24#include <utility>
25
26namespace QuantLib {
27
30 : baseVol_(baseVol), spread_(std::move(spread)) {
31 enableExtrapolation(baseVol->allowsExtrapolation());
34 }
35
36 ext::shared_ptr<SmileSection>
38 ext::shared_ptr<SmileSection> baseSmile =
39 baseVol_->smileSection(d, true);
40 return ext::shared_ptr<SmileSection>(new
41 SpreadedSmileSection(baseSmile, spread_));
42 }
43
44 ext::shared_ptr<SmileSection>
46 ext::shared_ptr<SmileSection> baseSmile =
47 baseVol_->smileSection(optionTime, true);
48 return ext::shared_ptr<SmileSection>(new
49 SpreadedSmileSection(baseSmile, spread_));
50 }
51
53 Rate s) const {
54 return baseVol_->volatility(t, s, true) + spread_->value();
55 }
56
57}
Concrete date class.
Definition: date.hpp:125
void enableExtrapolation(bool b=true)
enable extrapolation in subsequent calls
Shared handle to an observable.
Definition: handle.hpp:41
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
const Handle< OptionletVolatilityStructure > baseVol_
SpreadedOptionletVolatility(const Handle< OptionletVolatilityStructure > &, Handle< Quote > spread)
Volatility volatilityImpl(Time optionTime, Rate strike) const override
implements the actual volatility calculation in derived classes
ext::shared_ptr< SmileSection > smileSectionImpl(const Date &d) const override
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
Real Volatility
volatility
Definition: types.hpp:78
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35
STL namespace.