Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
spreadedcpivolatilitysurface.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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 spreadedoptionletvolatility2.hpp
20 \brief Optionlet volatility with overlayed bilinearly interpolated spread surface
21 \ingroup termstructures
22*/
23
24#pragma once
25
26#include <ql/math/interpolations/interpolation2d.hpp>
27#include <ql/patterns/lazyobject.hpp>
28#include <ql/quote.hpp>
30
31#include <boost/smart_ptr/shared_ptr.hpp>
32
33namespace QuantExt {
34using namespace QuantLib;
35
37public:
38 // warning we assume that volatilities are retrieved with obLag = -1D, i.e. using the standard lag from the ts
39 SpreadedCPIVolatilitySurface(const Handle<QuantExt::CPIVolatilitySurface>& baseVol,
40 const std::vector<Date>& optionDates,
41 const std::vector<Real>& strikes,
42 const std::vector<std::vector<Handle<Quote>>>& volSpreads);
43 Rate minStrike() const override;
44 Rate maxStrike() const override;
45 Date maxDate() const override;
46 Time maxTime() const override;
47 const Date& referenceDate() const override;
48 void update() override;
49 void deepUpdate() override;
50 QuantLib::Real atmStrike(const QuantLib::Date& maturity,
51 const QuantLib::Period& obsLag = QuantLib::Period(-1, QuantLib::Days)) const override;
52
53protected:
54 Volatility volatilityImpl(Time length, Rate strike) const override;
55 void performCalculations() const override;
56
57private:
58 Handle<QuantExt::CPIVolatilitySurface> baseVol_;
59 std::vector<Date> optionDates_;
60 std::vector<Real> strikes_;
61 std::vector<std::vector<Handle<Quote>>> volSpreads_;
62 //
63 mutable std::vector<Real> optionTimes_;
64 mutable Matrix volSpreadValues_;
65 mutable Interpolation2D volSpreadInterpolation_;
66};
67
68} // namespace QuantExt
Handle< QuantExt::CPIVolatilitySurface > baseVol_
Volatility volatilityImpl(Time length, Rate strike) const override
std::vector< std::vector< Handle< Quote > > > volSpreads_
QuantLib::Real atmStrike(const QuantLib::Date &maturity, const QuantLib::Period &obsLag=QuantLib::Period(-1, QuantLib::Days)) const override
interpolated correlation term structure
vector< Real > strikes