Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
volatilityconfig.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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 ored/configuration/commodityvolcurveconfig.hpp
20 \brief Commodity volatility curve configuration
21 \ingroup configuration
22*/
23
24#pragma once
25
28#include <ql/exercise.hpp>
29
30namespace ore {
31namespace data {
32
33/*! Shared volatility configurations
34 \ingroup configuration
35*/
37public:
38 VolatilityConfig(std::string calendarStr = std::string(), QuantLib::Natural priority = 0);
39
41 void toXMLNode(XMLDocument& doc, XMLNode* node) const;
42
43 QuantLib::Natural priority() const { return priority_; };
44 Calendar calendar() const { return calendar_; };
45
46private:
47 Calendar calendar_;
49 QuantLib::Natural priority_;
50};
51
52bool operator<(const VolatilityConfig& vc1, const VolatilityConfig& vc2);
53
55public:
57 ProxyVolatilityConfig(const std::string& proxyVolatilityCurve, const std::string& fxVolatilityCurve = "",
58 const std::string& correlationCurve = "", std::string calendarStr = std::string(),
59 QuantLib::Natural priority = 0)
60 : VolatilityConfig(calendarStr, priority),
63
64 //! \name Inspectors
65 //@{
66 const std::string& proxyVolatilityCurve() const;
67 const std::string& fxVolatilityCurve() const;
68 const std::string& correlationCurve() const;
69 //@}
70
71 //! \name Serialisation
72 //@{
73 void fromXML(ore::data::XMLNode* node) override;
75 //@}
76
77private:
79 std::string fxVolatilityCurve_;
80 std::string correlationCurve_;
81};
82
84public:
86 explicit CDSProxyVolatilityConfig(const std::string& cdsVolatilityCurve)
88
89 //! \name Inspectors
90 //@{
91 const std::string& cdsVolatilityCurve() const;
92 //@}
93
94 //! \name Serialisation
95 //@{
96 void fromXML(ore::data::XMLNode* node) override;
98 //@}
99
100private:
102};
103
105public:
106 //! Default constructor
108 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
109 std::string calendarStr = std::string(), QuantLib::Natural priority = 0)
111
112 //! \name Inspectors
113 //@{
114 const MarketDatum::QuoteType& quoteType() const { return quoteType_; }
115 const QuantLib::Exercise::Type& exerciseType() const { return exerciseType_; }
116 //@}
117
118 //! \name Serialisation
119 //@{
122 //@}
123
124private:
126 QuantLib::Exercise::Type exerciseType_;
127};
128
129/*! Volatility configuration for a single constant volatility
130 \ingroup configuration
131 */
133public:
134 //! Default constructor
136 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
137 std::string calendarStr = std::string(), QuantLib::Natural priority = 0);
138
139 //! Explicit constructor
140 ConstantVolatilityConfig(const std::string& quote,
142 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
143 std::string calendarStr = std::string(), QuantLib::Natural priority = 0);
144
145 //! \name Inspectors
146 //@{
147 const std::string& quote() const;
148 //@}
149
150 //! \name Serialisation
151 //@{
152 void fromXML(ore::data::XMLNode* node) override;
153 ore::data::XMLNode* toXML(ore::data::XMLDocument& doc) const override;
154 //@}
155
156private:
157 std::string quote_;
158};
159
160/*! Volatility configuration for a 1-D volatility curve
161 \ingroup configuration
162 */
164public:
165 //! Default constructor
167 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
168 bool enforceMontoneVariance = true, std::string calendarStr = std::string(),
169 QuantLib::Natural priority = 0);
170
171 //! Explicit constructor
172 VolatilityCurveConfig(const std::vector<std::string>& quotes, const std::string& interpolation,
173 const std::string& extrapolation,
175 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
176 bool enforceMontoneVariance = true, std::string calendarStr = std::string(),
177 QuantLib::Natural priority = 0);
178
179 //! \name Inspectors
180 //@{
181 const std::vector<std::string>& quotes() const;
182 const std::string& interpolation() const;
183 const std::string& extrapolation() const;
184 bool enforceMontoneVariance() const;
185 //@}
186
187 //! \name Serialisation
188 //@{
189 void fromXML(ore::data::XMLNode* node) override;
190 ore::data::XMLNode* toXML(ore::data::XMLDocument& doc) const override;
191 //@}
192
193private:
194 std::vector<std::string> quotes_;
195 std::string interpolation_;
196 std::string extrapolation_;
198};
199
200/*! Base volatility configuration for a 2-D volatility surface
201 \ingroup configuration
202 */
204public:
205 //! Default constructor
207 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
208 std::string calendarStr = std::string(), QuantLib::Natural priority = 0);
209
210 //! Explicit constructor
211 VolatilitySurfaceConfig(const std::string& timeInterpolation, const std::string& strikeInterpolation,
212 bool extrapolation, const std::string& timeExtrapolation,
213 const std::string& strikeExtrapolation,
215 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
216 std::string calendarStr = std::string(), QuantLib::Natural priority = 0);
217
218 //! \name Inspectors
219 //@{
220 const std::string& timeInterpolation() const;
221 const std::string& strikeInterpolation() const;
222 bool extrapolation() const;
223 const std::string& timeExtrapolation() const;
224 const std::string& strikeExtrapolation() const;
225 //@}
226
227 /*! Return a vector of pairs of expiry and strike. The first element in the pair is the expiry and the second
228 element in the pair is the string representation of the strike. This will be useful for building the vector
229 of quote strings in classes that have a VolatilitySurfaceConfig.
230 */
231 virtual std::vector<std::pair<std::string, std::string>> quotes() const = 0;
232
233protected:
234 /*! Populate members from the provided \p node. Can be called by fromXML in derived classes.
235 */
236 void fromNode(ore::data::XMLNode* node);
237
238 /*! Add members to the provided \p node. Can be called by toXML in derived classes.
239 */
240 void addNodes(ore::data::XMLDocument& doc, ore::data::XMLNode* node) const;
241
242private:
248};
249
250/*! Volatility configuration for a 2-D absolute strike volatility surface
251 \ingroup configuration
252 */
254public:
255 //! Default constructor
257 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
258 std::string calendarStr = std::string(), QuantLib::Natural priority = 0);
259
260 //! Explicit constructor
261 VolatilityStrikeSurfaceConfig(const std::vector<std::string>& strikes, const std::vector<std::string>& expiries,
262 const std::string& timeInterpolation, const std::string& strikeInterpolation,
263 bool extrapolation, const std::string& timeExtrapolation,
264 const std::string& strikeExtrapolation,
266 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
267 std::string calendarStr = std::string(), QuantLib::Natural priority = 0);
268
269 //! \name Inspectors
270 //@{
271 const std::vector<std::string>& strikes() const;
272 const std::vector<std::string>& expiries() const;
273 //@}
274
275 //! \name VolatilitySurfaceConfig
276 //@{
277 std::vector<std::pair<std::string, std::string>> quotes() const override;
278 //@}
279
280 //! \name Serialisation
281 //@{
282 void fromXML(ore::data::XMLNode* node) override;
283 ore::data::XMLNode* toXML(ore::data::XMLDocument& doc) const override;
284 //@}
285
286private:
287 std::vector<std::string> strikes_;
288 std::vector<std::string> expiries_;
289};
290
291/*! Volatility configuration for a 2-D delta volatility surface
292 \ingroup configuration
293 */
295public:
296 //! Default constructor
298 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
299 std::string calendarStr = std::string(), QuantLib::Natural priority = 0);
300
301 //! Explicit constructor
302 VolatilityDeltaSurfaceConfig(const std::string& deltaType, const std::string& atmType,
303 const std::vector<std::string>& putDeltas, const std::vector<std::string>& callDeltas,
304 const std::vector<std::string>& expiries, const std::string& timeInterpolation,
305 const std::string& strikeInterpolation, bool extrapolation,
306 const std::string& timeExtrapolation, const std::string& strikeExtrapolation,
307 const std::string& atmDeltaType = "", bool futurePriceCorrection = true,
309 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
310 std::string calendarStr = std::string(), QuantLib::Natural priority = 0);
311
312 //! \name Inspectors
313 //@{
314 const std::string& deltaType() const;
315 const std::string& atmType() const;
316 const std::vector<std::string>& putDeltas() const;
317 const std::vector<std::string>& callDeltas() const;
318 const std::vector<std::string>& expiries() const;
319 const std::string& atmDeltaType() const;
320 bool futurePriceCorrection() const;
321 //@}
322
323 //! \name VolatilitySurfaceConfig
324 //@{
325 std::vector<std::pair<std::string, std::string>> quotes() const override;
326 //@}
327
328 //! \name Serialisation
329 //@{
330 void fromXML(ore::data::XMLNode* node) override;
331 ore::data::XMLNode* toXML(ore::data::XMLDocument& doc) const override;
332 //@}
333
334private:
335 std::string deltaType_;
336 std::string atmType_;
337 std::vector<std::string> putDeltas_;
338 std::vector<std::string> callDeltas_;
339 std::vector<std::string> expiries_;
340 std::string atmDeltaType_;
342};
343
344/*! Volatility configuration for a 2-D moneyness volatility surface
345 \ingroup configuration
346 */
348public:
349 //! Default constructor
351 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
352 std::string calendarStr = std::string(), QuantLib::Natural priority = 0);
353
354 //! Explicit constructor
355 VolatilityMoneynessSurfaceConfig(const std::string& moneynessType, const std::vector<std::string>& moneynessLevels,
356 const std::vector<std::string>& expiries, const std::string& timeInterpolation,
357 const std::string& strikeInterpolation, bool extrapolation,
358 const std::string& timeExtrapolation, const std::string& strikeExtrapolation,
359 bool futurePriceCorrection = true,
361 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
362 std::string calendarStr = std::string(), QuantLib::Natural priority = 0);
363
364 //! \name Inspectors
365 //@{
366 const std::string& moneynessType() const;
367 const std::vector<std::string>& moneynessLevels() const;
368 const std::vector<std::string>& expiries() const;
369 bool futurePriceCorrection() const;
370 //@}
371
372 //! \name VolatilitySurfaceConfig
373 //@{
374 std::vector<std::pair<std::string, std::string>> quotes() const override;
375 //@}
376
377 //! \name Serialisation
378 //@{
379 void fromXML(ore::data::XMLNode* node) override;
380 ore::data::XMLNode* toXML(ore::data::XMLDocument& doc) const override;
381 //@}
382
383private:
384 std::string moneynessType_;
385 std::vector<std::string> moneynessLevels_;
386 std::vector<std::string> expiries_;
388};
389
390/*! Volatility configuration for an average future price option (APO) surface.
391 \ingroup configuration
392 */
394public:
395 //! Default constructor
397 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
398 std::string calendarStr = std::string(), QuantLib::Natural priority = 0);
399
400 //! Explicit constructor
401 VolatilityApoFutureSurfaceConfig(const std::vector<std::string>& moneynessLevels,
402 const std::string& baseVolatilityId, const std::string& basePriceCurveId,
403 const std::string& baseConventionsId, const std::string& timeInterpolation,
404 const std::string& strikeInterpolation, bool extrapolation,
405 const std::string& timeExtrapolation, const std::string& strikeExtrapolation,
406 QuantLib::Real beta = 0.0, const std::string& maxTenor = "",
408 QuantLib::Exercise::Type exerciseType = QuantLib::Exercise::Type::European,
409 std::string calendarStr = std::string(), QuantLib::Natural priority = 0);
410
411 //! \name Inspectors
412 //@{
413 const std::vector<std::string>& moneynessLevels() const;
414 const std::string& baseVolatilityId() const;
415 const std::string& basePriceCurveId() const;
416 const std::string& baseConventionsId() const;
417 QuantLib::Real beta() const;
418 const std::string& maxTenor() const;
419 //@}
420
421 //! \name VolatilitySurfaceConfig
422 //@{
423 std::vector<std::pair<std::string, std::string>> quotes() const override;
424 //@}
425
426 //! \name Serialisation
427 //@{
428 void fromXML(ore::data::XMLNode* node) override;
429 ore::data::XMLNode* toXML(ore::data::XMLDocument& doc) const override;
430 //@}
431
432private:
433 std::vector<std::string> moneynessLevels_;
434 std::string baseVolatilityId_;
435 std::string basePriceCurveId_;
437 QuantLib::Real beta_;
438 std::string maxTenor_;
439};
440
442public:
444 void fromXML(XMLNode* node) override;
445 XMLNode* toXML(ore::data::XMLDocument& doc) const override;
446
447 void loadVolatiltyConfigs(XMLNode* node);
448
449 const std::vector<QuantLib::ext::shared_ptr<VolatilityConfig>>& volatilityConfig() { return volatilityConfig_; };
450
451private:
452 std::vector<QuantLib::ext::shared_ptr<VolatilityConfig>> volatilityConfig_;
453};
454
455
456} // namespace data
457} // namespace ore
void fromXML(ore::data::XMLNode *node) override
CDSProxyVolatilityConfig(const std::string &cdsVolatilityCurve)
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
const std::string & cdsVolatilityCurve() const
void fromXML(ore::data::XMLNode *node) override
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
ConstantVolatilityConfig(const std::string &quote, MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Explicit constructor.
ConstantVolatilityConfig(MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Default constructor.
const std::string & quote() const
QuoteType
Supported market quote types.
const std::string & correlationCurve() const
const std::string & fxVolatilityCurve() const
void fromXML(ore::data::XMLNode *node) override
const std::string & proxyVolatilityCurve() const
ProxyVolatilityConfig(const std::string &proxyVolatilityCurve, const std::string &fxVolatilityCurve="", const std::string &correlationCurve="", std::string calendarStr=std::string(), QuantLib::Natural priority=0)
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
const MarketDatum::QuoteType & quoteType() const
QuoteBasedVolatilityConfig(MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Default constructor.
void fromBaseNode(ore::data::XMLNode *node)
void toBaseNode(ore::data::XMLDocument &doc, ore::data::XMLNode *node) const
const QuantLib::Exercise::Type & exerciseType() const
std::vector< std::pair< std::string, std::string > > quotes() const override
VolatilityApoFutureSurfaceConfig(const std::vector< std::string > &moneynessLevels, const std::string &baseVolatilityId, const std::string &basePriceCurveId, const std::string &baseConventionsId, const std::string &timeInterpolation, const std::string &strikeInterpolation, bool extrapolation, const std::string &timeExtrapolation, const std::string &strikeExtrapolation, QuantLib::Real beta=0.0, const std::string &maxTenor="", MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Explicit constructor.
void fromXML(ore::data::XMLNode *node) override
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
VolatilityApoFutureSurfaceConfig(MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Default constructor.
const std::vector< std::string > & moneynessLevels() const
const std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > & volatilityConfig()
void fromXML(XMLNode *node) override
std::vector< QuantLib::ext::shared_ptr< VolatilityConfig > > volatilityConfig_
XMLNode * toXML(ore::data::XMLDocument &doc) const override
QuantLib::Natural priority() const
void fromXMLNode(ore::data::XMLNode *node)
void toXMLNode(XMLDocument &doc, XMLNode *node) const
const std::string & interpolation() const
void fromXML(ore::data::XMLNode *node) override
std::vector< std::string > quotes_
const std::string & extrapolation() const
VolatilityCurveConfig(MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, bool enforceMontoneVariance=true, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Default constructor.
VolatilityCurveConfig(const std::vector< std::string > &quotes, const std::string &interpolation, const std::string &extrapolation, MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, bool enforceMontoneVariance=true, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Explicit constructor.
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
const std::vector< std::string > & quotes() const
std::vector< std::pair< std::string, std::string > > quotes() const override
const std::vector< std::string > & putDeltas() const
const std::vector< std::string > & callDeltas() const
void fromXML(ore::data::XMLNode *node) override
const std::vector< std::string > & expiries() const
const std::string & atmDeltaType() const
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
VolatilityDeltaSurfaceConfig(MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Default constructor.
VolatilityDeltaSurfaceConfig(const std::string &deltaType, const std::string &atmType, const std::vector< std::string > &putDeltas, const std::vector< std::string > &callDeltas, const std::vector< std::string > &expiries, const std::string &timeInterpolation, const std::string &strikeInterpolation, bool extrapolation, const std::string &timeExtrapolation, const std::string &strikeExtrapolation, const std::string &atmDeltaType="", bool futurePriceCorrection=true, MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Explicit constructor.
std::vector< std::pair< std::string, std::string > > quotes() const override
VolatilityMoneynessSurfaceConfig(MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Default constructor.
void fromXML(ore::data::XMLNode *node) override
const std::vector< std::string > & expiries() const
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
VolatilityMoneynessSurfaceConfig(const std::string &moneynessType, const std::vector< std::string > &moneynessLevels, const std::vector< std::string > &expiries, const std::string &timeInterpolation, const std::string &strikeInterpolation, bool extrapolation, const std::string &timeExtrapolation, const std::string &strikeExtrapolation, bool futurePriceCorrection=true, MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Explicit constructor.
const std::vector< std::string > & moneynessLevels() const
std::vector< std::pair< std::string, std::string > > quotes() const override
void fromXML(ore::data::XMLNode *node) override
VolatilityStrikeSurfaceConfig(const std::vector< std::string > &strikes, const std::vector< std::string > &expiries, const std::string &timeInterpolation, const std::string &strikeInterpolation, bool extrapolation, const std::string &timeExtrapolation, const std::string &strikeExtrapolation, MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Explicit constructor.
const std::vector< std::string > & expiries() const
const std::vector< std::string > & strikes() const
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
VolatilityStrikeSurfaceConfig(MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Default constructor.
const std::string & timeInterpolation() const
virtual std::vector< std::pair< std::string, std::string > > quotes() const =0
VolatilitySurfaceConfig(const std::string &timeInterpolation, const std::string &strikeInterpolation, bool extrapolation, const std::string &timeExtrapolation, const std::string &strikeExtrapolation, MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Explicit constructor.
void addNodes(ore::data::XMLDocument &doc, ore::data::XMLNode *node) const
VolatilitySurfaceConfig(MarketDatum::QuoteType quoteType=MarketDatum::QuoteType::RATE_LNVOL, QuantLib::Exercise::Type exerciseType=QuantLib::Exercise::Type::European, std::string calendarStr=std::string(), QuantLib::Natural priority=0)
Default constructor.
const std::string & strikeInterpolation() const
const std::string & strikeExtrapolation() const
void fromNode(ore::data::XMLNode *node)
const std::string & timeExtrapolation() const
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
Base class for all serializable classes.
Definition: xmlutils.hpp:101
@ data
Definition: log.hpp:77
Market data representation.
bool operator<(const Dividend &d1, const Dividend &d2)
Serializable Credit Default Swap.
Definition: namespaces.docs:23
XML utility functions.