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

#include <qle/models/carrmadanarbitragecheck.hpp>

+ Collaboration diagram for CarrMadanMarginalProbabilitySafeStrikes:

Public Member Functions

 CarrMadanMarginalProbabilitySafeStrikes (const std::vector< Real > &strikes, const Real forward, const std::vector< Real > &callPrices, const VolatilityType volType=ShiftedLognormal, const Real shift=0.0)
 
const std::vector< Real > & strikes () const
 
Real forward () const
 
const std::vector< Real > & callPrices () const
 
VolatilityType volatilityType () const
 
Real shift () const
 
bool arbitrageFree () const
 
const std::vector< bool > & callSpreadArbitrage () const
 
const std::vector< bool > & butterflyArbitrage () const
 
const std::vector< Real > & density () const
 

Private Attributes

std::vector< Real > strikes_
 
Real forward_
 
std::vector< Real > callPrices_
 
VolatilityType volType_
 
Real shift_
 
std::vector< boolvalidStrike_
 
std::vector< boolcallSpreadArbitrage_
 
std::vector< boolbutterflyArbitrage_
 
std::vector< Real > q_
 
bool smileIsArbitrageFree_
 

Detailed Description

Definition at line 68 of file carrmadanarbitragecheck.hpp.

Constructor & Destructor Documentation

◆ CarrMadanMarginalProbabilitySafeStrikes()

CarrMadanMarginalProbabilitySafeStrikes ( const std::vector< Real > &  strikes,
const Real  forward,
const std::vector< Real > &  callPrices,
const VolatilityType  volType = ShiftedLognormal,
const Real  shift = 0.0 
)

The callPrices should be non-discounted

Definition at line 274 of file carrmadanarbitragecheck.cpp.

280
281 QL_REQUIRE(strikes_.size() == callPrices_.size(), "CarrMadanMarginalProbabilitySafeStrikes: strike size ("
282 << strikes_.size() << ") must match callPrices size ("
283 << callPrices_.size() << ")");
284
285 // handle edge cases (no strikes given, invalid forward given)
286
287 if (strikes_.empty()) {
289 return;
290 }
291
292 if (volType == ShiftedLognormal && forward < -shift && !close_enough(forward, -shift)) {
294 callSpreadArbitrage_ = std::vector<bool>(strikes_.size(), false);
295 butterflyArbitrage_ = std::vector<bool>(strikes_.size(), false);
296 q_ = std::vector<Real>(strikes_.size(), 0.0);
297 return;
298 }
299
300 // identify the strikes that are not valid (i.e. < -shift)
301
302 validStrike_.resize(strikes_.size(), true);
303 for (Size i = 0; i < strikes_.size(); ++i) {
304 if (volType_ == ShiftedLognormal && (strikes_[i] < -shift && !close_enough(strikes[i], -shift))) {
305 validStrike_[i] = false;
306 }
307 }
308
309 // build input for regular CM class
310
311 std::vector<Real> regStrikes;
312 std::vector<Real> regCallPrices;
313
314 for (Size i = 0; i < validStrike_.size(); ++i) {
315 if (validStrike_[i]) {
316 regStrikes.push_back(strikes_[i]);
317 regCallPrices.push_back(callPrices_[i]);
318 }
319 }
320
321 // check if we have at least one strike > -shift
322
323 bool haveNonBoundaryStrike = false;
324 if (volType == Normal) {
325 haveNonBoundaryStrike = true;
326 } else {
327 for (auto const& k : regStrikes) {
328 if (volType_ == ShiftedLognormal && k > -shift && !close_enough(k, -shift)) {
329 haveNonBoundaryStrike = true;
330 }
331 }
332 }
333
334 // if no such strike exists, the result is trivial
335
336 if (!haveNonBoundaryStrike) {
338 callSpreadArbitrage_ = std::vector<bool>(1, false);
339 butterflyArbitrage_ = std::vector<bool>(1, false);
340 q_ = std::vector<Real>(1, 1.0);
341 }
342
343 // otherwise we call the regular CM class on the regular strikes
344
345 CarrMadanMarginalProbability cm(regStrikes, forward_, regCallPrices, volType_, shift_);
346
347 // the results are set for the regular strikes and filled with reasonable values for invalid strike positions
348
349 smileIsArbitrageFree_ = cm.arbitrageFree();
350 callSpreadArbitrage_ = std::vector<bool>(strikes_.size(), false);
351 butterflyArbitrage_ = std::vector<bool>(strikes_.size(), false);
352 q_ = std::vector<Real>(strikes_.size(), 0.0);
353
354 for (Size i = 0; i < validStrike_.size(); ++i) {
355 if (validStrike_[i]) {
356 callSpreadArbitrage_[i] = cm.callSpreadArbitrage()[i];
357 butterflyArbitrage_[i] = cm.butterflyArbitrage()[i];
358 q_[i] = cm.density()[i];
359 }
360 }
361}
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
+ Here is the call graph for this function:

Member Function Documentation

◆ strikes()

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

Definition at line 363 of file carrmadanarbitragecheck.cpp.

363{ return strikes_; }
+ Here is the caller graph for this function:

◆ forward()

Real forward ( ) const

Definition at line 364 of file carrmadanarbitragecheck.cpp.

364{ return forward_; }
+ Here is the caller graph for this function:

◆ callPrices()

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

Definition at line 365 of file carrmadanarbitragecheck.cpp.

365{ return callPrices_; }

◆ volatilityType()

VolatilityType volatilityType ( ) const

Definition at line 366 of file carrmadanarbitragecheck.cpp.

366{ return volType_; }

◆ shift()

Real shift ( ) const

Definition at line 367 of file carrmadanarbitragecheck.cpp.

367{ return shift_; }
+ Here is the caller graph for this function:

◆ arbitrageFree()

bool arbitrageFree ( ) const

Definition at line 369 of file carrmadanarbitragecheck.cpp.

369{ return smileIsArbitrageFree_; }

◆ callSpreadArbitrage()

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

Definition at line 371 of file carrmadanarbitragecheck.cpp.

371 {
373}

◆ butterflyArbitrage()

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

Definition at line 374 of file carrmadanarbitragecheck.cpp.

374 {
375 return butterflyArbitrage_;
376}

◆ density()

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

Definition at line 377 of file carrmadanarbitragecheck.cpp.

377{ return q_; }

Member Data Documentation

◆ strikes_

std::vector<Real> strikes_
private

Definition at line 88 of file carrmadanarbitragecheck.hpp.

◆ forward_

Real forward_
private

Definition at line 89 of file carrmadanarbitragecheck.hpp.

◆ callPrices_

std::vector<Real> callPrices_
private

Definition at line 90 of file carrmadanarbitragecheck.hpp.

◆ volType_

VolatilityType volType_
private

Definition at line 91 of file carrmadanarbitragecheck.hpp.

◆ shift_

Real shift_
private

Definition at line 92 of file carrmadanarbitragecheck.hpp.

◆ validStrike_

std::vector<bool> validStrike_
private

Definition at line 94 of file carrmadanarbitragecheck.hpp.

◆ callSpreadArbitrage_

std::vector<bool> callSpreadArbitrage_
private

Definition at line 96 of file carrmadanarbitragecheck.hpp.

◆ butterflyArbitrage_

std::vector<bool> butterflyArbitrage_
private

Definition at line 96 of file carrmadanarbitragecheck.hpp.

◆ q_

std::vector<Real> q_
private

Definition at line 97 of file carrmadanarbitragecheck.hpp.

◆ smileIsArbitrageFree_

bool smileIsArbitrageFree_
private

Definition at line 98 of file carrmadanarbitragecheck.hpp.