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

#include <ored/scripting/models/modelcg.hpp>

+ Inheritance diagram for ModelCG:
+ Collaboration diagram for ModelCG:

Public Types

enum class  Type { MC , FD }
 

Public Member Functions

 ModelCG (const QuantLib::Size n)
 
virtual ~ModelCG ()
 
QuantLib::ext::shared_ptr< QuantExt::ComputationGraphcomputationGraph ()
 
virtual Type type () const =0
 
virtual QuantLib::Size size () const
 
virtual Size trainingSamples () const
 
virtual void toggleTrainingPaths () const
 
virtual const Date & referenceDate () const =0
 
virtual const std::string & baseCcy () const =0
 
virtual std::size_t dt (const Date &d1, const Date &d2) const
 
virtual std::size_t pay (const std::size_t amount, const Date &obsdate, const Date &paydate, const std::string &currency) const =0
 
virtual std::size_t discount (const Date &obsdate, const Date &paydate, const std::string &currency) const =0
 
virtual std::size_t npv (const std::size_t amount, const Date &obsdate, const std::size_t filter, const boost::optional< long > &memSlot, const std::size_t addRegressor1, const std::size_t addRegressor2) const =0
 
virtual std::size_t eval (const std::string &index, const Date &obsdate, const Date &fwddate, const bool returnMissingFixingAsNull=false, const bool ignoreTodaysFixing=false) const =0
 
virtual std::size_t fwdCompAvg (const bool isAvg, const std::string &index, const Date &obsdate, const Date &start, const Date &end, const Real spread, const Real gearing, const Integer lookback, const Natural rateCutoff, const Natural fixingDays, const bool includeSpread, const Real cap, const Real floor, const bool nakedOption, const bool localCapFloor) const =0
 
virtual std::size_t barrierProbability (const std::string &index, const Date &obsdate1, const Date &obsdate2, const std::size_t barrier, const bool above) const =0
 
virtual std::size_t fxSpotT0 (const std::string &forCcy, const std::string &domCcy) const =0
 
virtual Real extractT0Result (const QuantExt::RandomVariable &value) const =0
 
virtual void resetNPVMem ()
 
const std::map< std::string, boost::any > & additionalResults () const
 
virtual std::size_t cgVersion () const =0
 
virtual const std::vector< std::vector< std::size_t > > & randomVariates () const =0
 
virtual std::vector< std::pair< std::size_t, double > > modelParameters () const =0
 
virtual std::vector< std::pair< std::size_t, std::function< double(void)> > > & modelParameterFunctors () const =0
 
virtual Real getDirectFxSpotT0 (const std::string &forCcy, const std::string &domCcy) const =0
 
virtual Real getDirectDiscountT0 (const Date &paydate, const std::string &currency) const =0
 
void calculate () const override
 

Protected Attributes

std::map< std::string, boost::any > additionalResults_
 
QuantLib::ext::shared_ptr< QuantExt::ComputationGraphg_
 

Private Member Functions

void performCalculations () const override
 

Private Attributes

const QuantLib::Size n_
 

Detailed Description

Definition at line 48 of file modelcg.hpp.

Member Enumeration Documentation

◆ Type

enum class Type
strong
Enumerator
MC 
FD 

Definition at line 50 of file modelcg.hpp.

Constructor & Destructor Documentation

◆ ModelCG()

ModelCG ( const QuantLib::Size  n)
explicit

Definition at line 26 of file modelcg.cpp.

26: n_(n) { g_ = QuantLib::ext::make_shared<QuantExt::ComputationGraph>(); }
QuantLib::ext::shared_ptr< QuantExt::ComputationGraph > g_
Definition: modelcg.hpp:149
const QuantLib::Size n_
Definition: modelcg.hpp:155

◆ ~ModelCG()

virtual ~ModelCG ( )
virtual

Definition at line 53 of file modelcg.hpp.

53{}

Member Function Documentation

◆ computationGraph()

QuantLib::ext::shared_ptr< QuantExt::ComputationGraph > computationGraph ( )

Definition at line 56 of file modelcg.hpp.

56{ return g_; }

◆ type()

virtual Type type ( ) const
pure virtual

Implemented in BlackScholesCGBase, and GaussianCamCG.

◆ size()

virtual QuantLib::Size size ( ) const
virtual

Reimplemented in GaussianCamCG.

Definition at line 62 of file modelcg.hpp.

62{ return n_; }
+ Here is the caller graph for this function:

◆ trainingSamples()

virtual Size trainingSamples ( ) const
virtual

Definition at line 65 of file modelcg.hpp.

65{ return QuantLib::Null<Size>(); }

◆ toggleTrainingPaths()

virtual void toggleTrainingPaths ( ) const
virtual

Definition at line 69 of file modelcg.hpp.

69{}

◆ referenceDate()

virtual const Date & referenceDate ( ) const
pure virtual

Implemented in BlackScholesCGBase, and GaussianCamCG.

+ Here is the caller graph for this function:

◆ baseCcy()

virtual const std::string & baseCcy ( ) const
pure virtual

Implemented in ModelCGImpl.

◆ dt()

std::size_t dt ( const Date &  d1,
const Date &  d2 
) const
virtual

Reimplemented in ModelCGImpl.

Definition at line 28 of file modelcg.cpp.

28 {
29 return cg_const(*g_, QuantLib::ActualActual(QuantLib::ActualActual::ISDA).yearFraction(d1, d2));
30}
std::size_t cg_const(ComputationGraph &g, const double value)
+ Here is the call graph for this function:

◆ pay()

virtual std::size_t pay ( const std::size_t  amount,
const Date &  obsdate,
const Date &  paydate,
const std::string &  currency 
) const
pure virtual

Implemented in ModelCGImpl.

◆ discount()

virtual std::size_t discount ( const Date &  obsdate,
const Date &  paydate,
const std::string &  currency 
) const
pure virtual

Implemented in ModelCGImpl.

◆ npv()

virtual std::size_t npv ( const std::size_t  amount,
const Date &  obsdate,
const std::size_t  filter,
const boost::optional< long > &  memSlot,
const std::size_t  addRegressor1,
const std::size_t  addRegressor2 
) const
pure virtual

Implemented in BlackScholesCGBase, and GaussianCamCG.

◆ eval()

virtual std::size_t eval ( const std::string &  index,
const Date &  obsdate,
const Date &  fwddate,
const bool  returnMissingFixingAsNull = false,
const bool  ignoreTodaysFixing = false 
) const
pure virtual

Implemented in ModelCGImpl.

◆ fwdCompAvg()

virtual std::size_t fwdCompAvg ( const bool  isAvg,
const std::string &  index,
const Date &  obsdate,
const Date &  start,
const Date &  end,
const Real  spread,
const Real  gearing,
const Integer  lookback,
const Natural  rateCutoff,
const Natural  fixingDays,
const bool  includeSpread,
const Real  cap,
const Real  floor,
const bool  nakedOption,
const bool  localCapFloor 
) const
pure virtual

Implemented in BlackScholesCGBase, and GaussianCamCG.

◆ barrierProbability()

virtual std::size_t barrierProbability ( const std::string &  index,
const Date &  obsdate1,
const Date &  obsdate2,
const std::size_t  barrier,
const bool  above 
) const
pure virtual

Implemented in ModelCGImpl.

◆ fxSpotT0()

virtual std::size_t fxSpotT0 ( const std::string &  forCcy,
const std::string &  domCcy 
) const
pure virtual

Implemented in ModelCGImpl.

◆ extractT0Result()

virtual Real extractT0Result ( const QuantExt::RandomVariable value) const
pure virtual

Implemented in ModelCGImpl.

◆ resetNPVMem()

virtual void resetNPVMem ( )
virtual

Definition at line 124 of file modelcg.hpp.

124{}

◆ additionalResults()

const std::map< std::string, boost::any > & additionalResults ( ) const

Definition at line 127 of file modelcg.hpp.

127{ return additionalResults_; }
std::map< std::string, boost::any > additionalResults_
Definition: modelcg.hpp:146

◆ cgVersion()

virtual std::size_t cgVersion ( ) const
pure virtual

Implemented in ModelCGImpl.

◆ randomVariates()

virtual const std::vector< std::vector< std::size_t > > & randomVariates ( ) const
pure virtual

Implemented in ModelCGImpl.

◆ modelParameters()

virtual std::vector< std::pair< std::size_t, double > > modelParameters ( ) const
pure virtual

Implemented in ModelCGImpl.

◆ modelParameterFunctors()

virtual std::vector< std::pair< std::size_t, std::function< double(void)> > > & modelParameterFunctors ( ) const
pure virtual

Implemented in ModelCGImpl.

◆ getDirectFxSpotT0()

virtual Real getDirectFxSpotT0 ( const std::string &  forCcy,
const std::string &  domCcy 
) const
pure virtual

Implemented in BlackScholesCGBase, and GaussianCamCG.

◆ getDirectDiscountT0()

virtual Real getDirectDiscountT0 ( const Date &  paydate,
const std::string &  currency 
) const
pure virtual

Implemented in BlackScholesCGBase, and GaussianCamCG.

◆ calculate()

void calculate ( ) const
override

Definition at line 142 of file modelcg.hpp.

142{ LazyObject::calculate(); }
+ Here is the caller graph for this function:

◆ performCalculations()

void performCalculations ( ) const
overrideprivate

Definition at line 152 of file modelcg.hpp.

152{}

Member Data Documentation

◆ additionalResults_

std::map<std::string, boost::any> additionalResults_
mutableprotected

Definition at line 146 of file modelcg.hpp.

◆ g_

QuantLib::ext::shared_ptr<QuantExt::ComputationGraph> g_
protected

Definition at line 149 of file modelcg.hpp.

◆ n_

const QuantLib::Size n_
private

Definition at line 155 of file modelcg.hpp.