Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
carrmadanarbitragecheck.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 models/carrmadanarbitragecheck.hpp
20 \brief arbitrage checks based on Carr, Madan, A note on sufficient conditions for no arbitrage (2005)
21 \ingroup models
22*/
23
24#pragma once
25
26#include <ql/termstructures/volatility/volatilitytype.hpp>
27#include <ql/types.hpp>
28
29#include <string>
30#include <vector>
31
32namespace QuantExt {
33
34using namespace QuantLib;
35
37public:
38 /*! The callPrices should be non-discounted */
39 CarrMadanMarginalProbability(const std::vector<Real>& strikes, const Real forward,
40 const std::vector<Real>& callPrices, const VolatilityType volType = ShiftedLognormal,
41 const Real shift = 0.0);
42
43 const std::vector<Real>& strikes() const;
44 Real forward() const;
45 const std::vector<Real>& callPrices() const;
46 VolatilityType volatilityType() const;
47 Real shift() const;
48
49 bool arbitrageFree() const;
50
51 const std::vector<bool>& callSpreadArbitrage() const;
52 const std::vector<bool>& butterflyArbitrage() const;
53 const std::vector<Real>& density() const;
54
55private:
56 std::vector<Real> strikes_;
58 std::vector<Real> callPrices_;
59 VolatilityType volType_;
60 Real shift_;
61
63 std::vector<Real> q_;
65};
66
67// accepts invalid forward and/or strikes (lt -shift) and performs the computation on the valid strikes only
69public:
70 /*! The callPrices should be non-discounted */
71 CarrMadanMarginalProbabilitySafeStrikes(const std::vector<Real>& strikes, const Real forward,
72 const std::vector<Real>& callPrices,
73 const VolatilityType volType = ShiftedLognormal, const Real shift = 0.0);
74
75 const std::vector<Real>& strikes() const;
76 Real forward() const;
77 const std::vector<Real>& callPrices() const;
78 VolatilityType volatilityType() const;
79 Real shift() const;
80
81 bool arbitrageFree() const;
82
83 const std::vector<bool>& callSpreadArbitrage() const;
84 const std::vector<bool>& butterflyArbitrage() const;
85 const std::vector<Real>& density() const;
86
87private:
88 std::vector<Real> strikes_;
90 std::vector<Real> callPrices_;
91 VolatilityType volType_;
92 Real shift_;
93
94 std::vector<bool> validStrike_;
95
97 std::vector<Real> q_;
99};
100
102public:
103 /*! The moneyness is defined as K / F, K = strike, F = forward at the relevant time.
104 The times and moneyness should be strictly increasing.
105 The outer vectors for call prices and the calendarAbritrage() result represent times, the inner strikes. */
106 CarrMadanSurface(const std::vector<Real>& times, const std::vector<Real>& moneyness, const Real spot,
107 const std::vector<Real>& forwards, const std::vector<std::vector<Real>>& callPrices);
108
109 const std::vector<Real>& times() const;
110 const std::vector<Real>& moneyness() const;
111 Real spot() const;
112 const std::vector<Real>& forwards() const;
113 const std::vector<std::vector<Real>>& callPrices() const;
114
115 bool arbitrageFree() const;
116
117 const std::vector<CarrMadanMarginalProbability>& timeSlices() const;
118
119 /* outer vector = times, length = number of result of times(),
120 inner vector = strikes, length = number of strikes */
121 const std::vector<std::vector<bool>>& callSpreadArbitrage() const;
122 const std::vector<std::vector<bool>>& butterflyArbitrage() const;
123 const std::vector<std::vector<bool>>& calendarArbitrage() const;
124
125private:
126 std::vector<Real> times_, moneyness_;
127 Real spot_;
128 std::vector<Real> forwards_;
129 std::vector<std::vector<Real>> callPrices_;
130
131 std::vector<CarrMadanMarginalProbability> timeSlices_;
134};
135
136template <class CarrMadanMarginalProbabilityClass>
137std::string arbitrageAsString(const CarrMadanMarginalProbabilityClass& cm);
138
139std::string arbitrageAsString(const CarrMadanSurface& cm);
140
141} // namespace QuantExt
const std::vector< bool > & butterflyArbitrage() const
const std::vector< Real > & strikes() const
const std::vector< bool > & callSpreadArbitrage() const
const std::vector< Real > & density() const
const std::vector< Real > & callPrices() const
const std::vector< std::vector< bool > > & butterflyArbitrage() const
std::vector< CarrMadanMarginalProbability > timeSlices_
const std::vector< Real > & times() const
std::vector< std::vector< bool > > butterflyArbitrage_
std::vector< std::vector< bool > > calendarArbitrage_
const std::vector< std::vector< bool > > & calendarArbitrage() const
std::vector< std::vector< Real > > callPrices_
const std::vector< std::vector< Real > > & callPrices() const
std::vector< std::vector< bool > > callSpreadArbitrage_
const std::vector< Real > & forwards() const
const std::vector< std::vector< bool > > & callSpreadArbitrage() const
const std::vector< CarrMadanMarginalProbability > & timeSlices() const
const std::vector< Real > & moneyness() const
std::string arbitrageAsString(const CarrMadanMarginalProbabilityClass &cm)