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

SurvivalProbabilityCalculator. More...

#include <orea/engine/cptycalculator.hpp>

+ Inheritance diagram for SurvivalProbabilityCalculator:
+ Collaboration diagram for SurvivalProbabilityCalculator:

Public Member Functions

 ~SurvivalProbabilityCalculator ()
 
 SurvivalProbabilityCalculator (const std::string &configuration, Size index=0)
 base ccy and index to write to More...
 
virtual void calculate (const std::string &name, Size nameIndex, const QuantLib::ext::shared_ptr< SimMarket > &simMarket, QuantLib::ext::shared_ptr< NPVCube > &outputCube, const Date &date, Size dateIndex, Size sample, bool isCloseOut=false) override
 
virtual void calculateT0 (const std::string &name, Size nameIndex, const QuantLib::ext::shared_ptr< SimMarket > &simMarket, QuantLib::ext::shared_ptr< NPVCube > &outputCube) override
 
- Public Member Functions inherited from CounterpartyCalculator
virtual ~CounterpartyCalculator ()
 
virtual void calculate (const std::string &name, Size nameIndex, const QuantLib::ext::shared_ptr< SimMarket > &simMarket, QuantLib::ext::shared_ptr< NPVCube > &outputCube, const Date &date, Size dateIndex, Size sample, bool isCloseOut=false)=0
 
virtual void calculateT0 (const std::string &name, Size nameIndex, const QuantLib::ext::shared_ptr< SimMarket > &simMarket, QuantLib::ext::shared_ptr< NPVCube > &outputCube)=0
 

Private Member Functions

Real survProb (const std::string &name, const QuantLib::ext::shared_ptr< SimMarket > &simMarket, const Date &date=Date())
 

Private Attributes

std::string configuration_
 
Size index_
 

Detailed Description

SurvivalProbabilityCalculator.

Calculate the survival probability of a counterparty If the SurvivalProbabilityCalculator() call throws, we log an exception and write 1 to the cube

Definition at line 75 of file cptycalculator.hpp.

Constructor & Destructor Documentation

◆ ~SurvivalProbabilityCalculator()

Definition at line 77 of file cptycalculator.hpp.

77{}

◆ SurvivalProbabilityCalculator()

SurvivalProbabilityCalculator ( const std::string &  configuration,
Size  index = 0 
)

base ccy and index to write to

Definition at line 79 of file cptycalculator.hpp.

Member Function Documentation

◆ calculate()

void calculate ( const std::string &  name,
Size  nameIndex,
const QuantLib::ext::shared_ptr< SimMarket > &  simMarket,
QuantLib::ext::shared_ptr< NPVCube > &  outputCube,
const Date &  date,
Size  dateIndex,
Size  sample,
bool  isCloseOut = false 
)
overridevirtual

Implements CounterpartyCalculator.

Definition at line 31 of file cptycalculator.cpp.

33 {
34 if (!isCloseOut)
35 outputCube->set(survProb(name, simMarket, date), nameIndex, dateIndex, sample, index_);
36}
Real survProb(const std::string &name, const QuantLib::ext::shared_ptr< SimMarket > &simMarket, const Date &date=Date())
+ Here is the call graph for this function:

◆ calculateT0()

void calculateT0 ( const std::string &  name,
Size  nameIndex,
const QuantLib::ext::shared_ptr< SimMarket > &  simMarket,
QuantLib::ext::shared_ptr< NPVCube > &  outputCube 
)
overridevirtual

Implements CounterpartyCalculator.

Definition at line 38 of file cptycalculator.cpp.

40 {
41 outputCube->setT0(survProb(name, simMarket), nameIndex, index_);
42}
+ Here is the call graph for this function:

◆ survProb()

Real survProb ( const std::string &  name,
const QuantLib::ext::shared_ptr< SimMarket > &  simMarket,
const Date &  date = Date() 
)
private

Definition at line 44 of file cptycalculator.cpp.

46 {
47 Real survivalProb = 1.0;
48
49 try {
50 Handle<DefaultProbabilityTermStructure> dts = simMarket->defaultCurve(name, configuration_)->curve();
51 QL_REQUIRE(!dts.empty(), "Default curve missing for counterparty " << name);
52 survivalProb = dts->survivalProbability(date == Date() ? dts->referenceDate() : date);
53 } catch (std::exception& e) {
54 ALOG("Failed to calculate surv prob of counterparty " << name << " : " << e.what());
55 survivalProb = 1.0;
56 } catch (...) {
57 ALOG("Failed to calculate surv prob of counterparty " << name << " : Unhandled Exception");
58 survivalProb = 1.0;
59 }
60 return survivalProb;
61}
#define ALOG(text)
+ Here is the caller graph for this function:

Member Data Documentation

◆ configuration_

std::string configuration_
private

Definition at line 94 of file cptycalculator.hpp.

◆ index_

Size index_
private

Definition at line 95 of file cptycalculator.hpp.