Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
CarrMadanSurface Class Reference

#include <qle/models/carrmadanarbitragecheck.hpp>

+ Collaboration diagram for CarrMadanSurface:

Public Member Functions

 CarrMadanSurface (const std::vector< Real > &times, const std::vector< Real > &moneyness, const Real spot, const std::vector< Real > &forwards, const std::vector< std::vector< Real > > &callPrices)
 
const std::vector< Real > & times () const
 
const std::vector< Real > & moneyness () const
 
Real spot () const
 
const std::vector< Real > & forwards () const
 
const std::vector< std::vector< Real > > & callPrices () const
 
bool arbitrageFree () const
 
const std::vector< CarrMadanMarginalProbability > & timeSlices () const
 
const std::vector< std::vector< bool > > & callSpreadArbitrage () const
 
const std::vector< std::vector< bool > > & butterflyArbitrage () const
 
const std::vector< std::vector< bool > > & calendarArbitrage () const
 

Private Attributes

std::vector< Real > times_
 
std::vector< Real > moneyness_
 
Real spot_
 
std::vector< Real > forwards_
 
std::vector< std::vector< Real > > callPrices_
 
std::vector< CarrMadanMarginalProbabilitytimeSlices_
 
bool surfaceIsArbitrageFree_
 
std::vector< std::vector< bool > > callSpreadArbitrage_
 
std::vector< std::vector< bool > > butterflyArbitrage_
 
std::vector< std::vector< bool > > calendarArbitrage_
 

Detailed Description

Definition at line 101 of file carrmadanarbitragecheck.hpp.

Constructor & Destructor Documentation

◆ CarrMadanSurface()

CarrMadanSurface ( const std::vector< Real > &  times,
const std::vector< Real > &  moneyness,
const Real  spot,
const std::vector< Real > &  forwards,
const std::vector< std::vector< Real > > &  callPrices 
)

The moneyness is defined as K / F, K = strike, F = forward at the relevant time. The times and moneyness should be strictly increasing. The outer vectors for call prices and the calendarAbritrage() result represent times, the inner strikes.

Definition at line 181 of file carrmadanarbitragecheck.cpp.

184
185 // checks
186
187 QL_REQUIRE(times_.size() == callPrices_.size(),
188 "CarrMadanSurface: times size (" << times_.size() << ") does not match callPrices outer vector size ("
189 << callPrices_.size() << ")");
190 QL_REQUIRE(times.size() == forwards_.size(), "CarrMadanSurface: times size (" << times_.size()
191 << ") does not match forwards size ("
192 << forwards_.size() << ")");
193
194 QL_REQUIRE(!times_.empty(), "CarrMadanSurface: times are empty");
195
196 for (Size i = 1; i < times_.size(); ++i) {
197 QL_REQUIRE(times_[i] > times_[i - 1] && !close_enough(times_[i], times_[i - 1]),
198 "CarrMadanSurface: times not increasing at index " << (i - 1) << ", " << i << ": " << times_[i - 1]
199 << ", " << times_[i]);
200 }
201
202 QL_REQUIRE(times_.front() > 0.0 || close_enough(times_.front(), 0.0),
203 "CarrMadanSurface: all input times must be positive or zero, got " << times_.front());
204
205 for (Size i = 0; i < times_.size(); ++i) {
206 QL_REQUIRE(callPrices_[i].size() == moneyness_.size(), "CarrMadanSurface: callPrices at time "
207 << times_[i] << "(" << callPrices_[i].size()
208 << ") should match moneyness size ("
209 << moneyness_.size() << ")");
210 }
211
212 // construct the time slices
213
215 for (Size i = 0; i < times_.size(); ++i) {
216 std::vector<Real> strikes(moneyness_.size());
217 Real f = forwards_[i];
218 std::transform(moneyness_.begin(), moneyness_.end(), strikes.begin(), [&f](Real m) { return m * f; });
219 timeSlices_.push_back(CarrMadanMarginalProbability(strikes, forwards_[i], callPrices_[i]));
221 callSpreadArbitrage_.push_back(timeSlices_.back().callSpreadArbitrage());
222 butterflyArbitrage_.push_back(timeSlices_.back().butterflyArbitrage());
223 }
224
225 // check for calendar arbitrage
226
227 calendarArbitrage_ = std::vector<std::vector<bool>>(times_.size(), std::vector<bool>(moneyness_.size()));
228 for (Size i = 0; i < moneyness_.size(); ++i) {
229 for (Size j = 0; j < times_.size() - 1; ++j) {
230 Real c2 = callPrices_[j + 1][i] * spot_ / forwards_[j + 1];
231 Real c1 = callPrices_[j][i] * spot_ / forwards_[j];
232 bool af = c2 > c1 || close_enough(c1, c2);
233 if (!af) {
234 calendarArbitrage_[j][i] = true;
235 calendarArbitrage_[j + 1][i] = true;
237 }
238 }
239 }
240}
std::vector< CarrMadanMarginalProbability > timeSlices_
const std::vector< Real > & times() const
std::vector< std::vector< bool > > butterflyArbitrage_
std::vector< std::vector< bool > > calendarArbitrage_
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< Real > & moneyness() const
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
vector< Real > strikes
+ Here is the call graph for this function:

Member Function Documentation

◆ times()

const std::vector< Real > & times ( ) const

Definition at line 242 of file carrmadanarbitragecheck.cpp.

242{ return times_; }
+ Here is the caller graph for this function:

◆ moneyness()

const std::vector< Real > & moneyness ( ) const

Definition at line 243 of file carrmadanarbitragecheck.cpp.

243{ return moneyness_; }
+ Here is the caller graph for this function:

◆ spot()

Real spot ( ) const

Definition at line 244 of file carrmadanarbitragecheck.cpp.

244{ return spot_; }

◆ forwards()

const std::vector< Real > & forwards ( ) const

Definition at line 245 of file carrmadanarbitragecheck.cpp.

245{ return forwards_; }

◆ callPrices()

const std::vector< std::vector< Real > > & callPrices ( ) const

Definition at line 246 of file carrmadanarbitragecheck.cpp.

246{ return callPrices_; }

◆ arbitrageFree()

bool arbitrageFree ( ) const

Definition at line 248 of file carrmadanarbitragecheck.cpp.

248{ return surfaceIsArbitrageFree_; }

◆ timeSlices()

const std::vector< CarrMadanMarginalProbability > & timeSlices ( ) const

Definition at line 254 of file carrmadanarbitragecheck.cpp.

254{ return timeSlices_; }
+ Here is the caller graph for this function:

◆ callSpreadArbitrage()

const std::vector< std::vector< bool > > & callSpreadArbitrage ( ) const

Definition at line 251 of file carrmadanarbitragecheck.cpp.

251{ return callSpreadArbitrage_; }

◆ butterflyArbitrage()

const std::vector< std::vector< bool > > & butterflyArbitrage ( ) const

Definition at line 252 of file carrmadanarbitragecheck.cpp.

252{ return butterflyArbitrage_; }

◆ calendarArbitrage()

const std::vector< std::vector< bool > > & calendarArbitrage ( ) const

Definition at line 249 of file carrmadanarbitragecheck.cpp.

249{ return calendarArbitrage_; }
+ Here is the caller graph for this function:

Member Data Documentation

◆ times_

std::vector<Real> times_
private

Definition at line 126 of file carrmadanarbitragecheck.hpp.

◆ moneyness_

std::vector<Real> moneyness_
private

Definition at line 126 of file carrmadanarbitragecheck.hpp.

◆ spot_

Real spot_
private

Definition at line 127 of file carrmadanarbitragecheck.hpp.

◆ forwards_

std::vector<Real> forwards_
private

Definition at line 128 of file carrmadanarbitragecheck.hpp.

◆ callPrices_

std::vector<std::vector<Real> > callPrices_
private

Definition at line 129 of file carrmadanarbitragecheck.hpp.

◆ timeSlices_

std::vector<CarrMadanMarginalProbability> timeSlices_
private

Definition at line 131 of file carrmadanarbitragecheck.hpp.

◆ surfaceIsArbitrageFree_

bool surfaceIsArbitrageFree_
private

Definition at line 132 of file carrmadanarbitragecheck.hpp.

◆ callSpreadArbitrage_

std::vector<std::vector<bool> > callSpreadArbitrage_
private

Definition at line 133 of file carrmadanarbitragecheck.hpp.

◆ butterflyArbitrage_

std::vector<std::vector<bool> > butterflyArbitrage_
private

Definition at line 133 of file carrmadanarbitragecheck.hpp.

◆ calendarArbitrage_

std::vector<std::vector<bool> > calendarArbitrage_
private

Definition at line 133 of file carrmadanarbitragecheck.hpp.