Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
strippedoptionletadapter2.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file qle/termstructures/strippedoptionletadapter2.hpp
20 \brief StrippedOptionlet Adapter (with a deeper update method, linear interpolation and optional flat extrapolation)
21 \ingroup termstructures
22*/
23
24#ifndef quantext_stripped_optionlet_adapter2_h
25#define quantext_stripped_optionlet_adapter2_h
26
27#include <ql/math/interpolation.hpp>
28#include <ql/math/interpolations/sabrinterpolation.hpp>
29#include <ql/termstructures/volatility/optionlet/optionletstripper.hpp>
30#include <ql/termstructures/volatility/optionlet/optionletvolatilitystructure.hpp>
31#include <ql/termstructures/volatility/optionlet/strippedoptionletbase.hpp>
32
33namespace QuantExt {
34
35/*! Adapter class for turning a StrippedOptionletBase object into an
36 OptionletVolatilityStructure.
37 \ingroup termstructures
38*/
39class StrippedOptionletAdapter2 : public QuantLib::OptionletVolatilityStructure, public QuantLib::LazyObject {
40public:
41 StrippedOptionletAdapter2(const QuantLib::ext::shared_ptr<QuantLib::StrippedOptionletBase>&,
42 const bool flatExtrapolation = false);
43
44 //! \name TermStructure interface
45 //@{
46 QuantLib::Date maxDate() const override;
47 //@}
48 //! \name VolatilityTermStructure interface
49 //@{
50 QuantLib::Rate minStrike() const override;
51 QuantLib::Rate maxStrike() const override;
52 //@}
53 //! \name LazyObject interface
54 //@{
55 void update() override;
56 void performCalculations() const override;
57 QuantLib::ext::shared_ptr<QuantLib::OptionletStripper> optionletStripper() const;
58 //@}
59 QuantLib::VolatilityType volatilityType() const override;
60 QuantLib::Real displacement() const override;
61
62protected:
63 //! \name OptionletVolatilityStructure interface
64 //@{
65 QuantLib::ext::shared_ptr<QuantLib::SmileSection> smileSectionImpl(QuantLib::Time optionTime) const override;
66
67 QuantLib::Volatility volatilityImpl(QuantLib::Time length, QuantLib::Rate strike) const override;
68 //@}
69private:
70 const QuantLib::ext::shared_ptr<QuantLib::StrippedOptionletBase> optionletStripper_;
71 QuantLib::Size nInterpolations_;
72 mutable std::vector<QuantLib::ext::shared_ptr<QuantLib::Interpolation> > strikeInterpolations_;
74};
75
77 optionletStripper_->update(); // just in case
78 TermStructure::update();
79 LazyObject::update();
80}
81
82inline QuantLib::ext::shared_ptr<QuantLib::OptionletStripper> StrippedOptionletAdapter2::optionletStripper() const {
83 return QuantLib::ext::dynamic_pointer_cast<QuantLib::OptionletStripper>(optionletStripper_);
84}
85} // namespace QuantExt
86
87#endif
QuantLib::Volatility volatilityImpl(QuantLib::Time length, QuantLib::Rate strike) const override
QuantLib::Rate maxStrike() const override
QuantLib::Rate minStrike() const override
QuantLib::ext::shared_ptr< QuantLib::SmileSection > smileSectionImpl(QuantLib::Time optionTime) const override
QuantLib::VolatilityType volatilityType() const override
const QuantLib::ext::shared_ptr< QuantLib::StrippedOptionletBase > optionletStripper_
QuantLib::Real displacement() const override
std::vector< QuantLib::ext::shared_ptr< QuantLib::Interpolation > > strikeInterpolations_
QuantLib::ext::shared_ptr< QuantLib::OptionletStripper > optionletStripper() const