Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
parametricvolatility.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2024 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 parametricvolatility.hpp
20 \brief cross-asset, generic volatility structure
21*/
22
23#pragma once
24
25#include <ql/handle.hpp>
26#include <ql/option.hpp>
27#include <ql/pricingengines/blackformula.hpp>
28#include <ql/quote.hpp>
29#include <ql/termstructures/yieldtermstructure.hpp>
30
31namespace QuantExt {
32
33using QuantLib::Null;
34using QuantLib::Real;
35
37public:
38 enum class MarketModelType { Black76 };
40
41 struct MarketSmile {
42 QuantLib::Real timeToExpiry;
43 // not mandatory, used e.g. for swaptions, but not cap / floors
44 QuantLib::Real underlyingLength = Null<Real>();
45 QuantLib::Real forward;
46 // this is also used as output lognormal shift for lnvol - type model variants
47 QuantLib::Real lognormalShift = 0.0;
48 // if empty, otm strikes are used
49 std::vector<QuantLib::Option::Type> optionTypes;
50 std::vector<QuantLib::Real> strikes;
51 std::vector<QuantLib::Real> marketQuotes;
52 };
53
55 ParametricVolatility(const std::vector<MarketSmile> marketSmiles, const MarketModelType marketModelType,
56 const MarketQuoteType inputMarketQuoteType,
57 const QuantLib::Handle<QuantLib::YieldTermStructure> discountCurve);
58
59 // if outputOptionType is none, otm strike is used (and call for atm)
60 Real convert(const Real inputQuote, const MarketQuoteType inputMarketQuoteType,
61 const QuantLib::Real inputLognormalShift, const boost::optional<QuantLib::Option::Type> inputOptionType,
62 const QuantLib::Real timeToExpiry, const QuantLib::Real strike, const QuantLib::Real forward,
63 const MarketQuoteType outputMarketQuoteType, const QuantLib::Real outputLognormalShift,
64 const boost::optional<QuantLib::Option::Type> outputOptionType = boost::none) const;
65
66 /* - if outputOptionType is none, otm strike is used
67 - the outputMarketQuoteType must always be given and can be different from input market quote type
68 - if outputLognormalShift is null, the input data = model's lognormal shift is used (only for
69 outputMarketQuoteType = ShiftedLognormalVolatility) */
70 virtual QuantLib::Real
71 evaluate(const QuantLib::Real timeToExpiry, const QuantLib::Real underlyingLength, const QuantLib::Real strike,
72 const QuantLib::Real forward, const MarketQuoteType outputMarketQuoteType,
73 const QuantLib::Real outputLognormalShift = QuantLib::Null<QuantLib::Real>(),
74 const boost::optional<QuantLib::Option::Type> outputOptionType = boost::none) const = 0;
75
76protected:
77 std::vector<MarketSmile> marketSmiles_;
80 QuantLib::Handle<QuantLib::YieldTermStructure> discountCurve_;
81};
82
83/* strict weak ordering on MarketPoint by lexicographic comparison, i.e.
84 (timeToExpiry1, underlyingLength1) < (timeToExpiry2, underlyingLength2)*/
86
87} // namespace QuantExt
std::vector< MarketSmile > marketSmiles_
Real convert(const Real inputQuote, const MarketQuoteType inputMarketQuoteType, const QuantLib::Real inputLognormalShift, const boost::optional< QuantLib::Option::Type > inputOptionType, const QuantLib::Real timeToExpiry, const QuantLib::Real strike, const QuantLib::Real forward, const MarketQuoteType outputMarketQuoteType, const QuantLib::Real outputLognormalShift, const boost::optional< QuantLib::Option::Type > outputOptionType=boost::none) const
QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve_
virtual QuantLib::Real evaluate(const QuantLib::Real timeToExpiry, const QuantLib::Real underlyingLength, const QuantLib::Real strike, const QuantLib::Real forward, const MarketQuoteType outputMarketQuoteType, const QuantLib::Real outputLognormalShift=QuantLib::Null< QuantLib::Real >(), const boost::optional< QuantLib::Option::Type > outputOptionType=boost::none) const =0
bool operator<(const Dividend &d1, const Dividend &d2)
std::vector< QuantLib::Option::Type > optionTypes