Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
CrossAssetModel Class Reference

Cross Asset Model. More...

#include <qle/models/crossassetmodel.hpp>

+ Inheritance diagram for CrossAssetModel:
+ Collaboration diagram for CrossAssetModel:

Classes

struct  cache_hasher
 
struct  cache_key
 

Public Types

enum class  AssetType : Size {
  IR = 0 , FX = 1 , INF = 2 , CR = 3 ,
  EQ = 4 , COM = 5 , CrState = 6
}
 
enum class  ModelType {
  LGM1F , HW , BS , DK ,
  CIRPP , JY , GAB , GENERIC
}
 
enum class  Discretization { Euler , Exact }
 

Public Member Functions

 CrossAssetModel (const std::vector< QuantLib::ext::shared_ptr< Parametrization > > &parametrizations, const Matrix &correlation=Matrix(), const SalvagingAlgorithm::Type salvaging=SalvagingAlgorithm::None, const IrModel::Measure measure=IrModel::Measure::LGM, const Discretization discretization=Discretization::Exact)
 
 CrossAssetModel (const std::vector< QuantLib::ext::shared_ptr< IrModel > > &currencyModels, const std::vector< QuantLib::ext::shared_ptr< FxBsParametrization > > &fxParametrizations, const Matrix &correlation=Matrix(), const SalvagingAlgorithm::Type salvaging=SalvagingAlgorithm::None, const IrModel::Measure measure=IrModel::Measure::LGM, const Discretization discretization=Discretization::Exact)
 
QuantLib::ext::shared_ptr< CrossAssetStateProcessstateProcess () const
 
Size dimension () const
 
Size brownians () const
 
Size auxBrownians () const
 
Size totalNumberOfParameters () const
 
Size components (const AssetType t) const
 
Size brownians (const AssetType t, const Size i) const
 
Size auxBrownians (const AssetType t, const Size i) const
 
Size stateVariables (const AssetType t, const Size i) const
 
ModelType modelType (const AssetType t, const Size i) const
 
IrModel::Measure measure () const
 
Size ccyIndex (const Currency &ccy) const
 
Size eqIndex (const std::string &eqName) const
 
Size infIndex (const std::string &index) const
 
Size crName (const std::string &name) const
 
Size comIndex (const std::string &comName) const
 
void update () override
 
void generateArguments () override
 
const std::vector< QuantLib::ext::shared_ptr< Parametrization > > & parametrizations () const
 
const QuantLib::ext::shared_ptr< Parametrizationir (const Size ccy) const
 
const QuantLib::ext::shared_ptr< Parametrizationfx (const Size ccy) const
 
const QuantLib::ext::shared_ptr< Parametrizationinf (const Size i) const
 
const QuantLib::ext::shared_ptr< Parametrizationcr (const Size i) const
 
const QuantLib::ext::shared_ptr< Parametrizationeq (const Size i) const
 
const QuantLib::ext::shared_ptr< Parametrizationcom (const Size i) const
 
const QuantLib::ext::shared_ptr< Parametrizationcrstate (const Size i) const
 
const QuantLib::ext::shared_ptr< IrModelirModel (const Size ccy) const
 
QuantLib::Real numeraire (const Size ccy, const QuantLib::Time t, const QuantLib::Array &x, const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), const QuantLib::Array &aux=Array()) const
 
QuantLib::Real discountBond (const Size ccy, const QuantLib::Time t, const QuantLib::Time T, const QuantLib::Array &x, const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve=Handle< YieldTermStructure >()) const
 
const QuantLib::ext::shared_ptr< HwModelhw (const Size ccy) const
 
const QuantLib::ext::shared_ptr< IrHwParametrizationirhw (const Size ccy) const
 
const QuantLib::ext::shared_ptr< LinearGaussMarkovModellgm (const Size ccy) const
 
const QuantLib::ext::shared_ptr< IrLgm1fParametrizationirlgm1f (const Size ccy) const
 
Real numeraire (const Size ccy, const Time t, const Real x, Handle< YieldTermStructure > discountCurve=Handle< YieldTermStructure >()) const
 
Real bankAccountNumeraire (const Size ccy, const Time t, const Real x, const Real y, Handle< YieldTermStructure > discountCurve=Handle< YieldTermStructure >()) const
 
Real discountBond (const Size ccy, const Time t, const Time T, const Real x, Handle< YieldTermStructure > discountCurve=Handle< YieldTermStructure >()) const
 
Real reducedDiscountBond (const Size ccy, const Time t, const Time T, const Real x, Handle< YieldTermStructure > discountCurve=Handle< YieldTermStructure >()) const
 
Real discountBondOption (const Size ccy, Option::Type type, const Real K, const Time t, const Time S, const Time T, Handle< YieldTermStructure > discountCurve=Handle< YieldTermStructure >()) const
 
const QuantLib::ext::shared_ptr< FxModelfxModel (const Size ccy) const
 
const QuantLib::ext::shared_ptr< FxBsParametrizationfxbs (const Size ccy) const
 
const QuantLib::ext::shared_ptr< InfDkParametrizationinfdk (const Size i) const
 
const QuantLib::ext::shared_ptr< InfJyParameterizationinfjy (const Size i) const
 Inflation JY component. More...
 
const QuantLib::ext::shared_ptr< CrLgm1fParametrizationcrlgm1f (const Size i) const
 
const QuantLib::ext::shared_ptr< CrCirppcrcirppModel (const Size i) const
 
const QuantLib::ext::shared_ptr< CrCirppParametrizationcrcirpp (const Size i) const
 
const QuantLib::ext::shared_ptr< EqBsParametrizationeqbs (const Size ccy) const
 
const QuantLib::ext::shared_ptr< CommodityModelcomModel (const Size com) const
 
const QuantLib::ext::shared_ptr< CommoditySchwartzParametrizationcombs (const Size ccy) const
 
const QuantLib::ext::shared_ptr< CrStateParametrizationcrstateParam (const Size index) const
 
const Matrix & correlation () const
 
void checkCorrelationMatrix () const
 
Size idx (const AssetType t, const Size i) const
 
Size cIdx (const AssetType t, const Size i, const Size offset=0) const
 
Size wIdx (const AssetType t, const Size i, const Size offset=0) const
 
Size pIdx (const AssetType t, const Size i, const Size offset=0) const
 
Real correlation (const AssetType s, const Size i, const AssetType t, const Size j, const Size iOffset=0, const Size jOffset=0) const
 
void setCorrelation (const AssetType s, const Size i, const AssetType t, const Size j, const Real value, const Size iOffset=0, const Size jOffset=0)
 
Discretization discretization () const
 
SalvagingAlgorithm::Type salvagingAlgorithm () const
 
void setIntegrationPolicy (const QuantLib::ext::shared_ptr< Integrator > integrator, const bool usePiecewiseIntegration=true) const
 
const QuantLib::ext::shared_ptr< Integrator > integrator () const
 
std::pair< Real, Real > infdkV (const Size i, const Time t, const Time T)
 
std::pair< Real, Real > infdkI (const Size i, const Time t, const Time T, const Real z, const Real y)
 
Real infdkYY (const Size i, const Time t, const Time S, const Time T, const Real z, const Real y, const Real irz)
 
std::pair< Real, Real > crlgm1fS (const Size i, const Size ccy, const Time t, const Time T, const Real z, const Real y) const
 
std::pair< Real, Real > crcirppS (const Size i, const Time t, const Time T, const Real y, const Real s) const
 
virtual Handle< DefaultProbabilityTermStructure > crTs (const Size i) const
 
virtual std::pair< Real, Real > crS (const Size i, const Size ccy, const Time t, const Time T, const Real z, const Real y) const
 
void calibrateIrLgm1fVolatilitiesIterative (const Size ccy, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &helpers, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >())
 
void calibrateIrLgm1fReversionsIterative (const Size ccy, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &helpers, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >())
 
void calibrateIrLgm1fGlobal (const Size ccy, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &helpers, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >())
 
void calibrateBsVolatilitiesIterative (const AssetType &assetType, const Size aIdx, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &helpers, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >())
 
void calibrateBsVolatilitiesGlobal (const AssetType &assetType, const Size aIdx, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &helpers, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >())
 
void calibrateInfDkVolatilitiesIterative (const Size index, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &helpers, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >())
 
void calibrateInfDkReversionsIterative (const Size index, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &helpers, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >())
 
void calibrateInfDkVolatilitiesGlobal (const Size index, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &helpers, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >())
 
void calibrateInfDkReversionsGlobal (const Size index, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &helpers, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >())
 
void calibrateInfJyGlobal (QuantLib::Size index, const std::vector< QuantLib::ext::shared_ptr< QuantLib::CalibrationHelper > > &helpers, QuantLib::OptimizationMethod &method, const QuantLib::EndCriteria &endCriteria, const std::map< QuantLib::Size, bool > &toCalibrate, const QuantLib::Constraint &constraint=QuantLib::Constraint(), const std::vector< QuantLib::Real > &weights=std::vector< QuantLib::Real >())
 
void calibrateInfJyIterative (QuantLib::Size inflationModelIndex, QuantLib::Size parameterIndex, const std::vector< QuantLib::ext::shared_ptr< QuantLib::CalibrationHelper > > &helpers, QuantLib::OptimizationMethod &method, const QuantLib::EndCriteria &endCriteria, const QuantLib::Constraint &constraint=QuantLib::Constraint(), const std::vector< QuantLib::Real > &weights=std::vector< QuantLib::Real >())
 
void calibrateCrLgm1fVolatilitiesIterative (const Size index, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &helpers, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >())
 
void calibrateCrLgm1fReversionsIterative (const Size index, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &helpers, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >())
 
std::vector< boolMoveParameter (const AssetType t, const Size param, const Size index, const Size i)
 
- Public Member Functions inherited from LinkableCalibratedModel
 LinkableCalibratedModel ()
 
void update () override
 
virtual void calibrate (const std::vector< QuantLib::ext::shared_ptr< CalibrationHelper > > &, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >(), const std::vector< bool > &fixParameters=std::vector< bool >())
 Calibrate to a set of market instruments (usually caps/swaptions) More...
 
virtual void calibrate (const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >(), const std::vector< bool > &fixParameters=std::vector< bool >())
 for backward compatibility More...
 
Real value (const Array &params, const std::vector< QuantLib::ext::shared_ptr< CalibrationHelper > > &)
 
Real value (const Array &params, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &)
 for backward compatibility More...
 
const QuantLib::ext::shared_ptr< Constraint > & constraint () const
 
EndCriteria::Type endCriteria () const
 Returns end criteria result. More...
 
const Array & problemValues () const
 Returns the problem values. More...
 
Array params () const
 Returns array of arguments on which calibration is done. More...
 
virtual void setParams (const Array &params)
 
virtual void setParam (Size idx, const Real value)
 

Static Public Attributes

static constexpr Size numberOfAssetTypes = 7
 

Protected Member Functions

 CrossAssetModel (const std::vector< QuantLib::ext::shared_ptr< Parametrization > > &parametrizations, const Matrix &correlation, SalvagingAlgorithm::Type salvaging, IrModel::Measure measure, const Discretization discretization, const bool)
 
Size arguments (const AssetType t, const Size i) const
 
Size aIdx (const AssetType t, const Size i, const Size offset=0) const
 
virtual std::pair< AssetType, ModelTypegetComponentType (const Size i) const
 
virtual Size getNumberOfParameters (const Size i) const
 
virtual Size getNumberOfBrownians (const Size i) const
 
virtual Size getNumberOfAuxBrownians (const Size i) const
 
virtual Size getNumberOfStateVariables (const Size i) const
 
void updateIndices (const AssetType &t, const Size i, const Size cIdx, const Size wIdx, const Size pIdx, const Size aIdx)
 
virtual void initialize ()
 
virtual void initializeParametrizations ()
 
virtual void initializeCorrelation ()
 
virtual void initializeArguments ()
 
virtual void finalizeArguments ()
 
virtual void checkModelConsistency () const
 
virtual void initDefaultIntegrator ()
 
Real infV (const Size idx, const Size ccy, const Time t, const Time T) const
 
Real crV (const Size idx, const Size ccy, const Time t, const Time T) const
 
void appendToFixedParameterVector (const AssetType t, const AssetType v, const Size param, const Size index, const Size i, std::vector< bool > &res)
 
virtual void generateArguments ()
 

Protected Attributes

boost::unordered_map< cache_key, std::pair< Real, Real >, cache_hashercache_crlgm1fS_
 
boost::unordered_map< cache_key, std::pair< Real, Real >, cache_hashercache_infdkI_
 
std::vector< Size > components_
 
std::vector< std::vector< Size > > idx_
 
std::vector< std::vector< Size > > cIdx_
 
std::vector< std::vector< Size > > wIdx_
 
std::vector< std::vector< Size > > pIdx_
 
std::vector< std::vector< Size > > aIdx_
 
std::vector< std::vector< Size > > brownians_
 
std::vector< std::vector< Size > > auxBrownians_
 
std::vector< std::vector< Size > > stateVariables_
 
std::vector< std::vector< Size > > numArguments_
 
Size totalDimension_
 
Size totalNumberOfBrownians_
 
Size totalNumberOfAuxBrownians_
 
Size totalNumberOfParameters_
 
std::vector< std::vector< ModelType > > modelType_
 
std::vector< QuantLib::ext::shared_ptr< Parametrization > > p_
 
std::vector< QuantLib::ext::shared_ptr< IrModel > > irModels_
 
std::vector< QuantLib::ext::shared_ptr< FxModel > > fxModels_
 
std::vector< QuantLib::ext::shared_ptr< CrCirpp > > crcirppModel_
 
std::vector< QuantLib::ext::shared_ptr< CommodityModel > > comModels_
 
Matrix rho_
 
SalvagingAlgorithm::Type salvaging_
 
IrModel::Measure measure_
 
Discretization discretization_
 
QuantLib::ext::shared_ptr< Integrator > integrator_
 
QuantLib::ext::shared_ptr< CrossAssetStateProcessstateProcess_
 
- Protected Attributes inherited from LinkableCalibratedModel
std::vector< QuantLib::ext::shared_ptr< Parameter > > arguments_
 
QuantLib::ext::shared_ptr< Constraintconstraint_
 
EndCriteria::Type endCriteria_
 
Array problemValues_
 

Detailed Description

Cross Asset Model.

Definition at line 58 of file crossassetmodel.hpp.

Member Enumeration Documentation

◆ AssetType

enum class AssetType : Size
strong

◆ ModelType

enum class ModelType
strong

◆ Discretization

enum class Discretization
strong

Constructor & Destructor Documentation

◆ CrossAssetModel() [1/3]

CrossAssetModel ( const std::vector< QuantLib::ext::shared_ptr< Parametrization > > &  parametrizations,
const Matrix &  correlation = Matrix(),
const SalvagingAlgorithm::Type  salvaging = SalvagingAlgorithm::None,
const IrModel::Measure  measure = IrModel::Measure::LGM,
const Discretization  discretization = Discretization::Exact 
)

Parametrizations must be given in the following order

  • IR (first parametrization defines the domestic currency)
  • FX (for all pairs domestic-ccy defined by the IR models)
  • INF (optionally, ccy must be a subset of the IR ccys)
  • CR (optionally, ccy must be a subset of the IR ccys)
  • EQ (for all names equity currency defined in Parametrization)
  • COM (for all names commodity currency defined in Parametrization) If the correlation matrix is not given, it is initialized as the unit matrix (and can be customized after construction of the model).

All IR components must be of type HW or LGM1F, i.e. you can't mix the two types.

Definition at line 87 of file crossassetmodel.cpp.

92 initialize();
93}
Discretization discretization() const
const std::vector< QuantLib::ext::shared_ptr< Parametrization > > & parametrizations() const
std::vector< QuantLib::ext::shared_ptr< Parametrization > > p_
SalvagingAlgorithm::Type salvaging_
const Matrix & correlation() const
IrModel::Measure measure() const
+ Here is the call graph for this function:

◆ CrossAssetModel() [2/3]

CrossAssetModel ( const std::vector< QuantLib::ext::shared_ptr< IrModel > > &  currencyModels,
const std::vector< QuantLib::ext::shared_ptr< FxBsParametrization > > &  fxParametrizations,
const Matrix &  correlation = Matrix(),
const SalvagingAlgorithm::Type  salvaging = SalvagingAlgorithm::None,
const IrModel::Measure  measure = IrModel::Measure::LGM,
const Discretization  discretization = Discretization::Exact 
)

IR-FX model based constructor

Definition at line 95 of file crossassetmodel.cpp.

99 : LinkableCalibratedModel(), irModels_(currencyModels), rho_(correlation), salvaging_(salvaging), measure_(measure),
101 for (Size i = 0; i < currencyModels.size(); ++i) {
102 p_.push_back(currencyModels[i]->parametrizationBase());
103 }
104 for (Size i = 0; i < fxParametrizations.size(); ++i) {
105 p_.push_back(fxParametrizations[i]);
106 }
107 initialize();
108}
std::vector< QuantLib::ext::shared_ptr< IrModel > > irModels_
+ Here is the call graph for this function:

◆ CrossAssetModel() [3/3]

CrossAssetModel ( const std::vector< QuantLib::ext::shared_ptr< Parametrization > > &  parametrizations,
const Matrix &  correlation,
SalvagingAlgorithm::Type  salvaging,
IrModel::Measure  measure,
const Discretization  discretization,
const bool   
)
protected

Member Function Documentation

◆ stateProcess()

QuantLib::ext::shared_ptr< CrossAssetStateProcess > stateProcess ( ) const

returns the state process with a given discretization

Definition at line 110 of file crossassetmodel.cpp.

110 {
111 if (stateProcess_ == nullptr) {
112 stateProcess_ = QuantLib::ext::make_shared<CrossAssetStateProcess>(shared_from_this());
113 }
114 return stateProcess_;
115}
QuantLib::ext::shared_ptr< CrossAssetStateProcess > stateProcess_
+ Here is the caller graph for this function:

◆ dimension()

Size dimension ( ) const

total dimension of model (sum of number of state variables)

Definition at line 513 of file crossassetmodel.hpp.

+ Here is the caller graph for this function:

◆ brownians() [1/2]

Size brownians ( ) const

total number of Brownian motions (excluding aux brownians)

Definition at line 515 of file crossassetmodel.hpp.

+ Here is the caller graph for this function:

◆ auxBrownians() [1/2]

Size auxBrownians ( ) const

total number of aux Brownian motions

Definition at line 517 of file crossassetmodel.hpp.

+ Here is the caller graph for this function:

◆ totalNumberOfParameters()

Size totalNumberOfParameters ( ) const

total number of parameters that can be calibrated

Definition at line 519 of file crossassetmodel.hpp.

◆ components()

Size components ( const AssetType  t) const

number of components for an asset class

Definition at line 117 of file crossassetmodel.cpp.

117{ return components_[(Size)t]; }
std::vector< Size > components_
+ Here is the caller graph for this function:

◆ brownians() [2/2]

Size brownians ( const AssetType  t,
const Size  i 
) const

number of brownian motions for a component excluding aux Brownians

Definition at line 176 of file crossassetmodel.cpp.

176 {
177 QL_REQUIRE(brownians_[(Size)t].size() > i,
178 "CrossAssetModel::brownians(): asset class " << t << ", component " << i << " not known.");
179 return brownians_[(Size)t][i];
180}
std::vector< std::vector< Size > > brownians_

◆ auxBrownians() [2/2]

Size auxBrownians ( const AssetType  t,
const Size  i 
) const

number of aux brownian motions for a component

Definition at line 182 of file crossassetmodel.cpp.

182 {
183 QL_REQUIRE(auxBrownians_[(Size)t].size() > i,
184 "CrossAssetModel::auxBrownians(): asset class " << t << ", component " << i << " not known.");
185 return auxBrownians_[(Size)t][i];
186}
std::vector< std::vector< Size > > auxBrownians_

◆ stateVariables()

Size stateVariables ( const AssetType  t,
const Size  i 
) const

number of state variables for a component

Definition at line 188 of file crossassetmodel.cpp.

188 {
189 QL_REQUIRE(stateVariables_[(Size)t].size() > i,
190 "CrossAssetModel::stateVariables(): asset class " << t << ", component " << i << " not known.");
191 return stateVariables_[(Size)t][i];
192}
std::vector< std::vector< Size > > stateVariables_
+ Here is the caller graph for this function:

◆ modelType()

CrossAssetModel::ModelType modelType ( const AssetType  t,
const Size  i 
) const

model type of a component

Definition at line 200 of file crossassetmodel.cpp.

200 {
201 QL_REQUIRE(modelType_[(Size)t].size() > i,
202 "CrossAssetModel::modelType(): asset class " << t << ", component " << i << " not known.");
203 return modelType_[(Size)t][i];
204}
std::vector< std::vector< ModelType > > modelType_
+ Here is the caller graph for this function:

◆ measure()

IrModel::Measure measure ( ) const

Choice of probability measure

Definition at line 122 of file crossassetmodel.hpp.

122{ return measure_; }
+ Here is the caller graph for this function:

◆ ccyIndex()

Size ccyIndex ( const Currency &  ccy) const

return index for currency (0 = domestic, 1 = first foreign currency and so on)

Definition at line 119 of file crossassetmodel.cpp.

119 {
120 Size i = 0;
121 while (i < components(CrossAssetModel::AssetType::IR) && ir(i)->currency() != ccy)
122 ++i;
124 "currency " << ccy.code() << " not present in cross asset model");
125 return i;
126}
Size components(const AssetType t) const
const QuantLib::ext::shared_ptr< Parametrization > ir(const Size ccy) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqIndex()

Size eqIndex ( const std::string &  eqName) const

return index for equity (0 = first equity)

Definition at line 128 of file crossassetmodel.cpp.

128 {
129 Size i = 0;
130 while (i < components(CrossAssetModel::AssetType::EQ) && eq(i)->name() != name)
131 ++i;
133 "equity name " << name << " not present in cross asset model");
134 return i;
135}
const QuantLib::ext::shared_ptr< Parametrization > eq(const Size i) const
+ Here is the call graph for this function:

◆ infIndex()

Size infIndex ( const std::string &  index) const

return index for inflation (0 = first inflation index)

Definition at line 146 of file crossassetmodel.cpp.

146 {
147 Size i = 0;
148 while (i < components(CrossAssetModel::AssetType::INF) && inf(i)->name() != index)
149 ++i;
151 "inflation index " << index << " not present in cross asset model");
152 return i;
153}
const QuantLib::ext::shared_ptr< Parametrization > inf(const Size i) const
+ Here is the call graph for this function:

◆ crName()

Size crName ( const std::string &  name) const

return index for credit (0 = first credit name)

Definition at line 155 of file crossassetmodel.cpp.

155 {
156 Size i = 0;
157 while (i < components(CrossAssetModel::AssetType::CR) && cr(i)->name() != name)
158 ++i;
160 "credit name " << name << " not present in cross asset model");
161 return i;
162}
const QuantLib::ext::shared_ptr< Parametrization > cr(const Size i) const
+ Here is the call graph for this function:

◆ comIndex()

Size comIndex ( const std::string &  comName) const

return index for commodity (0 = first equity)

Definition at line 137 of file crossassetmodel.cpp.

137 {
138 Size i = 0;
139 while (i < components(CrossAssetModel::AssetType::COM) && com(i)->name() != name)
140 ++i;
142 "commodity name " << name << " not present in cross asset model");
143 return i;
144}
const QuantLib::ext::shared_ptr< Parametrization > com(const Size i) const
+ Here is the call graph for this function:

◆ update()

void update ( )
override

observer and linked calibrated model interface

Definition at line 164 of file crossassetmodel.cpp.

164 {
165 cache_crlgm1fS_.clear();
166 cache_infdkI_.clear();
167 for (Size i = 0; i < p_.size(); ++i) {
168 p_[i]->update();
169 }
170 stateProcess()->resetCache(0); // disable cache
171 notifyObservers();
172}
QuantLib::ext::shared_ptr< CrossAssetStateProcess > stateProcess() const
boost::unordered_map< cache_key, std::pair< Real, Real >, cache_hasher > cache_crlgm1fS_
boost::unordered_map< cache_key, std::pair< Real, Real >, cache_hasher > cache_infdkI_
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateArguments()

void generateArguments ( )
overridevirtual

Reimplemented from LinkableCalibratedModel.

Definition at line 174 of file crossassetmodel.cpp.

174{ update(); }
+ Here is the call graph for this function:

◆ parametrizations()

const std::vector< QuantLib::ext::shared_ptr< Parametrization > > & parametrizations ( ) const

the vector of parametrizations

Definition at line 145 of file crossassetmodel.hpp.

145{ return p_; }

◆ ir()

const QuantLib::ext::shared_ptr< Parametrization > ir ( const Size  ccy) const

components per asset class, see below for specific model type inspectors

Definition at line 521 of file crossassetmodel.hpp.

521 {
523}
Size idx(const AssetType t, const Size i) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fx()

const QuantLib::ext::shared_ptr< Parametrization > fx ( const Size  ccy) const

Definition at line 525 of file crossassetmodel.hpp.

525 {
527}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ inf()

const QuantLib::ext::shared_ptr< Parametrization > inf ( const Size  i) const

Definition at line 529 of file crossassetmodel.hpp.

529 {
531}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cr()

const QuantLib::ext::shared_ptr< Parametrization > cr ( const Size  i) const

Definition at line 533 of file crossassetmodel.hpp.

533 {
535}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eq()

const QuantLib::ext::shared_ptr< Parametrization > eq ( const Size  i) const

Definition at line 537 of file crossassetmodel.hpp.

537 {
538 return QuantLib::ext::static_pointer_cast<Parametrization>(p_[idx(CrossAssetModel::AssetType::EQ, i)]);
539}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ com()

const QuantLib::ext::shared_ptr< Parametrization > com ( const Size  i) const

Definition at line 541 of file crossassetmodel.hpp.

541 {
542 return QuantLib::ext::static_pointer_cast<Parametrization>(p_[idx(CrossAssetModel::AssetType::COM, i)]);
543}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crstate()

const QuantLib::ext::shared_ptr< Parametrization > crstate ( const Size  i) const

◆ irModel()

const QuantLib::ext::shared_ptr< IrModel > irModel ( const Size  ccy) const

Definition at line 545 of file crossassetmodel.hpp.

545 {
546 return irModels_[ccy];
547}
+ Here is the caller graph for this function:

◆ numeraire() [1/2]

QuantLib::Real numeraire ( const Size  ccy,
const QuantLib::Time  t,
const QuantLib::Array &  x,
const QuantLib::Handle< QuantLib::YieldTermStructure > &  discountCurve = Handle<YieldTermStructure>(),
const QuantLib::Array &  aux = Array() 
) const

numeraire

Definition at line 628 of file crossassetmodel.hpp.

630 {
631 return irModel(ccy)->numeraire(t, x, discountCurve, aux);
632}
const QuantLib::ext::shared_ptr< IrModel > irModel(const Size ccy) const
+ Here is the call graph for this function:

◆ discountBond() [1/2]

QuantLib::Real discountBond ( const Size  ccy,
const QuantLib::Time  t,
const QuantLib::Time  T,
const QuantLib::Array &  x,
const QuantLib::Handle< QuantLib::YieldTermStructure > &  discountCurve = Handle< YieldTermStructure >() 
) const

discount bond

◆ hw()

const QuantLib::ext::shared_ptr< HwModel > hw ( const Size  ccy) const

HW components, ccy=0 refers to the domestic currency

Definition at line 557 of file crossassetmodel.hpp.

557 {
558 auto tmp = QuantLib::ext::dynamic_pointer_cast<HwModel>(irModels_[idx(CrossAssetModel::AssetType::IR, ccy)]);
559 QL_REQUIRE(tmp, "model at " << ccy << " is not IR-HW");
560 return tmp;
561}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ irhw()

const QuantLib::ext::shared_ptr< IrHwParametrization > irhw ( const Size  ccy) const

Definition at line 563 of file crossassetmodel.hpp.

563 {
564 return hw(ccy)->parametrization();
565}
const QuantLib::ext::shared_ptr< HwModel > hw(const Size ccy) const
+ Here is the call graph for this function:

◆ lgm()

const QuantLib::ext::shared_ptr< LinearGaussMarkovModel > lgm ( const Size  ccy) const

LGM1F components, ccy=0 refers to the domestic currency

Definition at line 567 of file crossassetmodel.hpp.

567 {
568 auto tmp = QuantLib::ext::dynamic_pointer_cast<LinearGaussMarkovModel>(irModels_[idx(CrossAssetModel::AssetType::IR, ccy)]);
569 QL_REQUIRE(tmp, "model at " << ccy << " is not IR-LGM1F");
570 return tmp;
571}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ irlgm1f()

const QuantLib::ext::shared_ptr< IrLgm1fParametrization > irlgm1f ( const Size  ccy) const

Definition at line 573 of file crossassetmodel.hpp.

573 {
574 return lgm(ccy)->parametrization();
575}
const QuantLib::ext::shared_ptr< LinearGaussMarkovModel > lgm(const Size ccy) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ numeraire() [2/2]

Real numeraire ( const Size  ccy,
const Time  t,
const Real  x,
Handle< YieldTermStructure >  discountCurve = Handle<YieldTermStructure>() 
) const

DEPRECATED LGM measure numeraire

Definition at line 634 of file crossassetmodel.hpp.

635 {
636 return lgm(ccy)->numeraire(t, x, discountCurve);
637}
+ Here is the call graph for this function:

◆ bankAccountNumeraire()

Real bankAccountNumeraire ( const Size  ccy,
const Time  t,
const Real  x,
const Real  y,
Handle< YieldTermStructure >  discountCurve = Handle<YieldTermStructure>() 
) const

DEPRECATED LGM - Bank account measure numeraire B(t) as a function of drifted LGM state variable x and drift-free auxiliary state variable y

Definition at line 639 of file crossassetmodel.hpp.

640 {
641 return lgm(ccy)->bankAccountNumeraire(t, x, y, discountCurve);
642}
+ Here is the call graph for this function:

◆ discountBond() [2/2]

Real discountBond ( const Size  ccy,
const Time  t,
const Time  T,
const Real  x,
Handle< YieldTermStructure >  discountCurve = Handle<YieldTermStructure>() 
) const

DEPRECATED LGM specific discountBond

Definition at line 644 of file crossassetmodel.hpp.

645 {
646 return lgm(ccy)->discountBond(t, T, x, discountCurve);
647}
+ Here is the call graph for this function:

◆ reducedDiscountBond()

Real reducedDiscountBond ( const Size  ccy,
const Time  t,
const Time  T,
const Real  x,
Handle< YieldTermStructure >  discountCurve = Handle<YieldTermStructure>() 
) const

DEPRECATED LGM specific discountBond

Definition at line 649 of file crossassetmodel.hpp.

650 {
651 return lgm(ccy)->reducedDiscountBond(t, T, x, discountCurve);
652}
+ Here is the call graph for this function:

◆ discountBondOption()

Real discountBondOption ( const Size  ccy,
Option::Type  type,
const Real  K,
const Time  t,
const Time  S,
const Time  T,
Handle< YieldTermStructure >  discountCurve = Handle<YieldTermStructure>() 
) const

DEPRECATED LGM specific discountBond

Definition at line 654 of file crossassetmodel.hpp.

656 {
657 return lgm(ccy)->discountBondOption(type, K, t, S, T, discountCurve);
658}
+ Here is the call graph for this function:

◆ fxModel()

const QuantLib::ext::shared_ptr< FxModel > fxModel ( const Size  ccy) const

Definition at line 549 of file crossassetmodel.hpp.

549 {
550 return fxModels_[ccy];
551}
std::vector< QuantLib::ext::shared_ptr< FxModel > > fxModels_

◆ fxbs()

const QuantLib::ext::shared_ptr< FxBsParametrization > fxbs ( const Size  ccy) const

FXBS components, ccy=0 referes to the first foreign currency, so it corresponds to ccy+1 if you want to get the corresponding irmgl1f component

Definition at line 660 of file crossassetmodel.hpp.

660 {
661 QuantLib::ext::shared_ptr<FxBsParametrization> tmp =
662 QuantLib::ext::dynamic_pointer_cast<FxBsParametrization>(p_[idx(CrossAssetModel::AssetType::FX, ccy)]);
663 QL_REQUIRE(tmp, "model at " << ccy << " is not FX-BS");
664 return tmp;
665}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infdk()

const QuantLib::ext::shared_ptr< InfDkParametrization > infdk ( const Size  i) const

INF DK components

Definition at line 577 of file crossassetmodel.hpp.

577 {
578 QuantLib::ext::shared_ptr<InfDkParametrization> tmp =
579 QuantLib::ext::dynamic_pointer_cast<InfDkParametrization>(p_[idx(CrossAssetModel::AssetType::INF, i)]);
580 QL_REQUIRE(tmp, "model at " << i << " is not INF-DK");
581 return tmp;
582}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infjy()

const QuantLib::ext::shared_ptr< InfJyParameterization > infjy ( const Size  i) const

Inflation JY component.

Definition at line 584 of file crossassetmodel.hpp.

584 {
585 auto tmp = QuantLib::ext::dynamic_pointer_cast<InfJyParameterization>(p_[idx(CrossAssetModel::AssetType::INF, i)]);
586 QL_REQUIRE(tmp, "model at " << i << " is not INF-JY");
587 return tmp;
588}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crlgm1f()

const QuantLib::ext::shared_ptr< CrLgm1fParametrization > crlgm1f ( const Size  i) const

CR LGM 1F components

Definition at line 590 of file crossassetmodel.hpp.

590 {
591 QuantLib::ext::shared_ptr<CrLgm1fParametrization> tmp =
592 QuantLib::ext::dynamic_pointer_cast<CrLgm1fParametrization>(p_[idx(CrossAssetModel::AssetType::CR, i)]);
593 QL_REQUIRE(tmp, "model at " << i << " is not CR-LGM");
594 return tmp;
595}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crcirppModel()

const QuantLib::ext::shared_ptr< CrCirpp > crcirppModel ( const Size  i) const

CR CIR++ components

Definition at line 597 of file crossassetmodel.hpp.

597 {
598 QuantLib::ext::shared_ptr<CrCirpp> tmp = crcirppModel_[i];
599 QL_REQUIRE(tmp, "model at " << i << " is not CR-CIRPP");
600 return tmp;
601}
std::vector< QuantLib::ext::shared_ptr< CrCirpp > > crcirppModel_

◆ crcirpp()

const QuantLib::ext::shared_ptr< CrCirppParametrization > crcirpp ( const Size  i) const

Definition at line 603 of file crossassetmodel.hpp.

603 {
604 QuantLib::ext::shared_ptr<CrCirppParametrization> tmp =
605 QuantLib::ext::dynamic_pointer_cast<CrCirppParametrization>(p_[idx(CrossAssetModel::AssetType::CR, i)]);
606 QL_REQUIRE(tmp, "model at " << i << " is not CR-CIRPP");
607 return tmp;
608}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqbs()

const QuantLib::ext::shared_ptr< EqBsParametrization > eqbs ( const Size  ccy) const

EQBS components

Definition at line 610 of file crossassetmodel.hpp.

610 {
611 QuantLib::ext::shared_ptr<EqBsParametrization> tmp =
612 QuantLib::ext::dynamic_pointer_cast<EqBsParametrization>(p_[idx(CrossAssetModel::AssetType::EQ, name)]);
613 QL_REQUIRE(tmp, "model at " << name << " is not EQ-BS");
614 return tmp;
615}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ comModel()

const QuantLib::ext::shared_ptr< CommodityModel > comModel ( const Size  com) const

Definition at line 553 of file crossassetmodel.hpp.

553 {
554 return comModels_[com];
555}
std::vector< QuantLib::ext::shared_ptr< CommodityModel > > comModels_
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ combs()

const QuantLib::ext::shared_ptr< CommoditySchwartzParametrization > combs ( const Size  ccy) const

COMBS components

Definition at line 617 of file crossassetmodel.hpp.

617 {
618 QuantLib::ext::shared_ptr<CommoditySchwartzParametrization> tmp =
619 QuantLib::ext::dynamic_pointer_cast<CommoditySchwartzParametrization>(p_[idx(CrossAssetModel::AssetType::COM, name)]);
620 QL_REQUIRE(tmp, "model at " << name << " is not COM-BS");
621 return tmp;
622}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crstateParam()

const QuantLib::ext::shared_ptr< CrStateParametrization > crstateParam ( const Size  index) const

CreditState components

Definition at line 624 of file crossassetmodel.hpp.

624 {
625 return QuantLib::ext::static_pointer_cast<CrStateParametrization>(p_[idx(CrossAssetModel::AssetType::CrState, i)]);
626}
+ Here is the call graph for this function:

◆ correlation() [1/2]

const Matrix & correlation ( ) const

correlation linking the different marginal models, note that the use of asset class pairs specific inspectors is recommended instead of the global matrix directly

Definition at line 667 of file crossassetmodel.hpp.

667{ return rho_; }
+ Here is the caller graph for this function:

◆ checkCorrelationMatrix()

void checkCorrelationMatrix ( ) const

check if correlation matrix is valid

Definition at line 663 of file crossassetmodel.cpp.

663 {
664 Size n = rho_.rows();
665 Size m = rho_.columns();
666 QL_REQUIRE(rho_.columns() == n, "correlation matrix (" << n << " x " << m << " must be square");
667 for (Size i = 0; i < n; ++i) {
668 for (Size j = 0; j < m; ++j) {
669 QL_REQUIRE(close_enough(rho_[i][j], rho_[j][i]), "correlation matrix is not symmetric, for (i,j)=("
670 << i << "," << j << ") rho(i,j)=" << rho_[i][j]
671 << " but rho(j,i)=" << rho_[j][i]);
672 QL_REQUIRE(close_enough(std::abs(rho_[i][j]), 1.0) || (rho_[i][j] > -1.0 && rho_[i][j] < 1.0),
673 "correlation matrix has invalid entry at (i,j)=(" << i << "," << j << ") equal to "
674 << rho_[i][j]);
675 }
676 QL_REQUIRE(close_enough(rho_[i][i], 1.0), "correlation matrix must have unit diagonal elements, "
677 "but rho(i,i)="
678 << rho_[i][i] << " for i=" << i);
679 }
680
681 // if we salvage the matrix there is no point in checking for negative eigenvalues prior to that
682 if (salvaging_ == SalvagingAlgorithm::None) {
683 SymmetricSchurDecomposition ssd(rho_);
684 for (Size i = 0; i < ssd.eigenvalues().size(); ++i) {
685 QL_REQUIRE(ssd.eigenvalues()[i] >= 0.0,
686 "correlation matrix has negative eigenvalue at " << i << " (" << ssd.eigenvalues()[i] << ")");
687 }
688 }
689}
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ idx()

Size idx ( const AssetType  t,
const Size  i 
) const

index of component in the parametrization vector

Definition at line 206 of file crossassetmodel.cpp.

206 {
207 QL_REQUIRE(idx_[(Size)t].size() > i,
208 "CrossAssetModel::idx(): asset class " << t << ", component " << i << " not known.");
209 return idx_[(Size)t][i];
210}
std::vector< std::vector< Size > > idx_
+ Here is the caller graph for this function:

◆ cIdx()

Size cIdx ( const AssetType  t,
const Size  i,
const Size  offset = 0 
) const

index of component in the correlation matrix, by offset

Definition at line 212 of file crossassetmodel.cpp.

212 {
213 QL_REQUIRE(offset < brownians(t, i), "c-offset (" << offset << ") for asset class " << t << " and index " << i
214 << " must be in 0..." << brownians(t, i) - 1);
215 QL_REQUIRE(cIdx_[(Size)t].size() > i,
216 "CrossAssetModel::cIdx(): asset class " << t << ", component " << i << " not known.");
217 return cIdx_[(Size)t][i] + offset;
218}
std::vector< std::vector< Size > > cIdx_
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wIdx()

Size wIdx ( const AssetType  t,
const Size  i,
const Size  offset = 0 
) const

index of component in the Brownian vector (including aux brownians), by offset this is checked to be equal to cIdx for Euler discretization and pIdx for exact discretization as an internal assertion

Definition at line 220 of file crossassetmodel.cpp.

220 {
221 QL_REQUIRE(offset < brownians(t, i) + auxBrownians(t, i), "c-offset (" << offset << ") for asset class " << t
222 << " and index " << i << " must be in 0..."
223 << brownians(t, i) + auxBrownians(t, i) - 1);
224 QL_REQUIRE(wIdx_[(Size)t].size() > i,
225 "CrossAssetModel::wIdx(): asset class " << t << ", component " << i << " not known.");
226 return wIdx_[(Size)t][i] + offset;
227}
std::vector< std::vector< Size > > wIdx_
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pIdx()

Size pIdx ( const AssetType  t,
const Size  i,
const Size  offset = 0 
) const

index of component in the stochastic process array, by offset

Definition at line 229 of file crossassetmodel.cpp.

229 {
230 QL_REQUIRE(offset < stateVariables(t, i), "p-offset (" << offset << ") for asset class " << t << " and index " << i
231 << " must be in 0..." << stateVariables(t, i) - 1);
232 QL_REQUIRE(pIdx_[(Size)t].size() > i,
233 "CrossAssetModel::pIdx(): asset class " << t << ", component " << i << " not known.");
234 return pIdx_[(Size)t][i] + offset;
235}
std::vector< std::vector< Size > > pIdx_
Size stateVariables(const AssetType t, const Size i) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ correlation() [2/2]

Real correlation ( const AssetType  s,
const Size  i,
const AssetType  t,
const Size  j,
const Size  iOffset = 0,
const Size  jOffset = 0 
) const

correlation between two components

Definition at line 245 of file crossassetmodel.cpp.

246 {
247 return rho_(cIdx(s, i, iOffset), cIdx(t, j, jOffset));
248}
Size cIdx(const AssetType t, const Size i, const Size offset=0) const
+ Here is the call graph for this function:

◆ setCorrelation()

void setCorrelation ( const AssetType  s,
const Size  i,
const AssetType  t,
const Size  j,
const Real  value,
const Size  iOffset = 0,
const Size  jOffset = 0 
)

set correlation

Definition at line 250 of file crossassetmodel.cpp.

251 {
252 Size row = cIdx(s, i, iOffset);
253 Size column = cIdx(t, j, jOffset);
254 QL_REQUIRE(row != column || close_enough(value, 1.0), "correlation must be 1 at (" << row << "," << column << ")");
255 QL_REQUIRE(value >= -1.0 && value <= 1.0, "correlation must be in [-1,1] at (" << row << "," << column << ")");
256 // we can not check for non-negative eigenvalues, since we do not
257 // know when the correlation matrix setup is finished, but this
258 // is effectively one in the state process later on anyway and
259 // the user can also use checkCorrelationMatrix() to verify this
260 rho_(row, column) = rho_(column, row) = value;
261 update();
262}
Real value(const Array &params, const std::vector< QuantLib::ext::shared_ptr< CalibrationHelper > > &)
+ Here is the call graph for this function:

◆ discretization()

Discretization discretization ( ) const

get discretization

Definition at line 264 of file crossassetmodel.hpp.

264{ return discretization_; }

◆ salvagingAlgorithm()

SalvagingAlgorithm::Type salvagingAlgorithm ( ) const

get salvaging algorithm

Definition at line 267 of file crossassetmodel.hpp.

267{ return salvaging_; }

◆ setIntegrationPolicy()

void setIntegrationPolicy ( const QuantLib::ext::shared_ptr< Integrator >  integrator,
const bool  usePiecewiseIntegration = true 
) const

analytical moments require numerical integration, which can be customized here

Definition at line 277 of file crossassetmodel.cpp.

278 {
279
280 if (!usePiecewiseIntegration) {
282 return;
283 }
284
285 // collect relevant times from parametrizations, we don't have to sort them or make them unique,
286 // this is all done in PiecewiseIntegral for us
287
288 std::vector<Time> allTimes;
289 for (Size i = 0; i < p_.size(); ++i) {
290 for (Size j = 0; j < getNumberOfParameters(i); ++j)
291 allTimes.insert(allTimes.end(), p_[i]->parameterTimes(j).begin(), p_[i]->parameterTimes(j).end());
292 }
293
294 // use piecewise integrator avoiding the step points
295 integrator_ = QuantLib::ext::make_shared<PiecewiseIntegral>(integrator, allTimes, true);
296}
const QuantLib::ext::shared_ptr< Integrator > integrator() const
virtual Size getNumberOfParameters(const Size i) const
QuantLib::ext::shared_ptr< Integrator > integrator_
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ integrator()

const QuantLib::ext::shared_ptr< Integrator > integrator ( ) const

Definition at line 669 of file crossassetmodel.hpp.

669{ return integrator_; }
+ Here is the caller graph for this function:

◆ infdkV()

std::pair< Real, Real > infdkV ( const Size  i,
const Time  t,
const Time  T 
)

return (V(t), V^tilde(t,T)) in the notation of the book

Definition at line 868 of file crossassetmodel.cpp.

868 {
869 Size ccy = ccyIndex(infdk(i)->currency());
870 cache_key k = {i, ccy, t, T};
871 boost::unordered_map<cache_key, std::pair<Real, Real>>::const_iterator it = cache_infdkI_.find(k);
872 Real V0, V_tilde;
873
874 if (it == cache_infdkI_.end()) {
875 V0 = infV(i, ccy, 0, t);
876 V_tilde = infV(i, ccy, t, T) - infV(i, ccy, 0, T) + infV(i, ccy, 0, t);
877 cache_infdkI_.insert(std::make_pair(k, std::make_pair(V0, V_tilde)));
878 } else {
879 // take V0 and V_tilde from cache
880 V0 = it->second.first;
881 V_tilde = it->second.second;
882 }
883 return std::make_pair(V0, V_tilde);
884}
const QuantLib::ext::shared_ptr< InfDkParametrization > infdk(const Size i) const
Size ccyIndex(const Currency &ccy) const
Real infV(const Size idx, const Size ccy, const Time t, const Time T) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infdkI()

std::pair< Real, Real > infdkI ( const Size  i,
const Time  t,
const Time  T,
const Real  z,
const Real  y 
)

return (I(t), I^tilde(t,T)) in the notation of the book, note that I(0) is normalized to 1 here, i.e. you have to multiply the result with the index value (as of the base date of the inflation ts)

Definition at line 886 of file crossassetmodel.cpp.

886 {
887 QL_REQUIRE(t < T || close_enough(t, T), "infdkI: t (" << t << ") <= T (" << T << ") required");
888 Real V0, V_tilde;
889 std::pair<Real, Real> Vs = infdkV(i, t, T);
890 V0 = Vs.first;
891 V_tilde = Vs.second;
892 Real Hyt = Hy(i).eval(*this, t);
893 Real HyT = Hy(i).eval(*this, T);
894
895 // TODO account for seasonality ...
896 // compute final results depending on z and y
897 const auto& zts = infdk(i)->termStructure();
898 auto dc = irlgm1f(0)->termStructure()->dayCounter();
899 bool indexIsInterpolated = true; // FIXME, though in line with the comment below
900 Real growth_t = inflationGrowth(zts, t, dc, indexIsInterpolated);
901 Real It = growth_t * std::exp(Hyt * z - y - V0);
902 Real Itilde_t_T = inflationGrowth(zts, T, dc, indexIsInterpolated) / growth_t * std::exp((HyT - Hyt) * z + V_tilde);
903 // concerning interpolation there is an inaccuracy here: if the index
904 // is not interpolated, we still simulate the index value as of t
905 // (and T), although we should go back to t, T which corresponds to
906 // the last actual publication time of the index => is the approximation
907 // here in this sense good enough that we can tolerate this?
908 return std::make_pair(It, Itilde_t_T);
909}
std::pair< Real, Real > infdkV(const Size i, const Time t, const Time T)
const QuantLib::ext::shared_ptr< IrLgm1fParametrization > irlgm1f(const Size ccy) const
Real inflationGrowth(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, Size index, Time S, Time T, Real irState, Real rrState, bool indexIsInterpolated)
INF H component. May relate to real rate portion of JY model or z component of DK model.
QuantLib::Real eval(const CrossAssetModel &x, const QuantLib::Real t) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infdkYY()

Real infdkYY ( const Size  i,
const Time  t,
const Time  S,
const Time  T,
const Real  z,
const Real  y,
const Real  irz 
)

return YoYIIS(t) in the notation of the book, the year on year swaplet price from S to T, at time t

Definition at line 911 of file crossassetmodel.cpp.

912 {
913 Size ccy = ccyIndex(infdk(i)->currency());
914
915 // Set Convexity adjustment set to 1.
916 // TODO: Add calculation for DK convexity adjustment
917 Real C_tilde = 1;
918
919 Real I_tildeS = infdkI(i, t, S, z, y).second;
920 Real I_tildeT = infdkI(i, t, T, z, y).second;
921 Real Pn_t_T = lgm(ccy)->discountBond(t, T, irz);
922
923 Real yySwaplet = (I_tildeT / I_tildeS) * Pn_t_T * C_tilde - Pn_t_T;
924
925 return yySwaplet;
926}
std::pair< Real, Real > infdkI(const Size i, const Time t, const Time T, const Real z, const Real y)
+ Here is the call graph for this function:

◆ crlgm1fS()

std::pair< Real, Real > crlgm1fS ( const Size  i,
const Size  ccy,
const Time  t,
const Time  T,
const Real  z,
const Real  y 
) const

returns (S(t), S^tilde(t,T)) in the notation of the book

Definition at line 928 of file crossassetmodel.cpp.

929 {
931 "ccy index (" << ccy << ") must be in 0..." << (components(CrossAssetModel::AssetType::IR) - 1));
932 QL_REQUIRE(t < T || close_enough(t, T), "crlgm1fS: t (" << t << ") <= T (" << T << ") required");
934 "model at " << i << " is not CR-LGM1F");
935 cache_key k = {i, ccy, t, T};
936 boost::unordered_map<cache_key, std::pair<Real, Real>>::const_iterator it = cache_crlgm1fS_.find(k);
937 Real V0, V_tilde;
938 Real Hlt = Hl(i).eval(*this, t);
939 Real HlT = Hl(i).eval(*this, T);
940
941 if (it == cache_crlgm1fS_.end()) {
942 // compute V0 and V_tilde
943 if (ccy == 0) {
944 // domestic credit
945 Real Hzt = Hz(0).eval(*this, t);
946 Real HzT = Hz(0).eval(*this, T);
947 Real zetal0 = zetal(i).eval(*this, t);
948 Real zetal1 = integral(*this, P(Hl(i), al(i), al(i)), 0.0, t);
949 Real zetal2 = integral(*this, P(Hl(i), Hl(i), al(i), al(i)), 0.0, t);
950 Real zetanl0 = integral(*this, P(rzl(0, i), az(0), al(i)), 0.0, t);
951 Real zetanl1 = integral(*this, P(rzl(0, i), Hl(i), az(0), al(i)), 0.0, t);
952 // opposite signs for last two terms in the book
953 V0 = 0.5 * Hlt * Hlt * zetal0 - Hlt * zetal1 + 0.5 * zetal2 + Hzt * Hlt * zetanl0 - Hzt * zetanl1;
954 V_tilde = -0.5 * (HlT * HlT - Hlt * Hlt) * zetal0 + (HlT - Hlt) * zetal1 -
955 (HzT * HlT - Hzt * Hlt) * zetanl0 + (HzT - Hzt) * zetanl1;
956 } else {
957 // foreign credit
958 V0 = crV(i, ccy, 0, t);
959 V_tilde = crV(i, ccy, t, T) - crV(i, ccy, 0, T) + crV(i, ccy, 0, t);
960 }
961 cache_crlgm1fS_.insert(std::make_pair(k, std::make_pair(V0, V_tilde)));
962 } else {
963 // take V0 and V_tilde from cache
964 V0 = it->second.first;
965 V_tilde = it->second.second;
966 }
967 // compute final results depending on z and y
968 // opposite sign for V0 in the book
969 Real St = crlgm1f(i)->termStructure()->survivalProbability(t) * std::exp(-Hlt * z + y - V0);
970 Real Stilde_t_T = crlgm1f(i)->termStructure()->survivalProbability(T) /
971 crlgm1f(i)->termStructure()->survivalProbability(t) * std::exp(-(HlT - Hlt) * z + V_tilde);
972 return std::make_pair(St, Stilde_t_T);
973}
const QuantLib::ext::shared_ptr< CrLgm1fParametrization > crlgm1f(const Size i) const
Real crV(const Size idx, const Size ccy, const Time t, const Time T) const
ModelType modelType(const AssetType t, const Size i) const
Real integral(const CrossAssetModel &model, const E &e, const Real a, const Real b)
const P2_< E1, E2 > P(const E1 &e1, const E2 &e2)
Real eval(const CrossAssetModel &x, const Real t) const
Real eval(const CrossAssetModel &x, const Real t) const
Real eval(const CrossAssetModel &x, const Real t) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crcirppS()

std::pair< Real, Real > crcirppS ( const Size  i,
const Time  t,
const Time  T,
const Real  y,
const Real  s 
) const

returns (S(t), S^tilde(t,T)) in the notation of the book

Definition at line 975 of file crossassetmodel.cpp.

976 {
978 "model at " << i << " is not CR-CIR");
979 if (close_enough(t, T))
980 return std::make_pair(s, 1.0);
981 else
982 return std::make_pair(s, crcirppModel_[i]->survivalProbability(t, T, y));
983}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crTs()

Handle< DefaultProbabilityTermStructure > crTs ( const Size  i) const
virtual

tentative: more generic interface that is agnostic of the model type - so far only for CR

Definition at line 671 of file crossassetmodel.hpp.

671 {
673 return crlgm1f(i)->termStructure();
675 return crcirpp(i)->termStructure();
676 QL_FAIL("model at " << i << " is not CR-*");
677}
const QuantLib::ext::shared_ptr< CrCirppParametrization > crcirpp(const Size i) const
+ Here is the call graph for this function:

◆ crS()

std::pair< Real, Real > crS ( const Size  i,
const Size  ccy,
const Time  t,
const Time  T,
const Real  z,
const Real  y 
) const
virtual

Definition at line 679 of file crossassetmodel.hpp.

680 {
682 return crlgm1fS(i, ccy, t, T, z, y);
684 QL_REQUIRE(ccy == 0, "CrossAssetModelPlus::crS() only implemented for ccy=0, got " << ccy);
685 return crcirppS(i, t, T, z, y);
686 }
687 QL_FAIL("model at " << i << " is not CR-*");
688}
std::pair< Real, Real > crlgm1fS(const Size i, const Size ccy, const Time t, const Time T, const Real z, const Real y) const
std::pair< Real, Real > crcirppS(const Size i, const Time t, const Time T, const Real y, const Real s) const
+ Here is the call graph for this function:

◆ calibrateIrLgm1fVolatilitiesIterative()

void calibrateIrLgm1fVolatilitiesIterative ( const Size  ccy,
const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  helpers,
OptimizationMethod method,
const EndCriteria &  endCriteria,
const Constraint constraint = Constraint(),
const std::vector< Real > &  weights = std::vector<Real>() 
)

calibration procedures

calibrate irlgm1f volatilities to a sequence of ir options with expiry times equal to step times in the parametrization

Definition at line 725 of file crossassetmodel.cpp.

727 {
728 lgm(ccy)->calibrateVolatilitiesIterative(helpers, method, endCriteria, constraint, weights);
729 update();
730}
const QuantLib::ext::shared_ptr< Constraint > & constraint() const
EndCriteria::Type endCriteria() const
Returns end criteria result.
+ Here is the call graph for this function:

◆ calibrateIrLgm1fReversionsIterative()

void calibrateIrLgm1fReversionsIterative ( const Size  ccy,
const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  helpers,
OptimizationMethod method,
const EndCriteria &  endCriteria,
const Constraint constraint = Constraint(),
const std::vector< Real > &  weights = std::vector<Real>() 
)

calibrate irlgm1f reversion to a sequence of ir options with maturities equal to step times in the parametrization

Definition at line 732 of file crossassetmodel.cpp.

734 {
735 lgm(ccy)->calibrateReversionsIterative(helpers, method, endCriteria, constraint, weights);
736 update();
737}
+ Here is the call graph for this function:

◆ calibrateIrLgm1fGlobal()

void calibrateIrLgm1fGlobal ( const Size  ccy,
const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  helpers,
OptimizationMethod method,
const EndCriteria &  endCriteria,
const Constraint constraint = Constraint(),
const std::vector< Real > &  weights = std::vector<Real>() 
)

calibrate irlgm1f parameters for one ccy globally to a set of ir options

Definition at line 739 of file crossassetmodel.cpp.

742 {
743 lgm(ccy)->calibrate(helpers, method, endCriteria, constraint, weights);
744 update();
745}
+ Here is the call graph for this function:

◆ calibrateBsVolatilitiesIterative()

void calibrateBsVolatilitiesIterative ( const AssetType assetType,
const Size  aIdx,
const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  helpers,
OptimizationMethod method,
const EndCriteria &  endCriteria,
const Constraint constraint = Constraint(),
const std::vector< Real > &  weights = std::vector<Real>() 
)

calibrate eq or fx volatilities to a sequence of options with expiry times equal to step times in the parametrization

Definition at line 747 of file crossassetmodel.cpp.

750 {
751 QL_REQUIRE(assetType == CrossAssetModel::AssetType::FX || assetType == CrossAssetModel::AssetType::EQ,
752 "Unsupported AssetType for BS calibration");
753 for (Size i = 0; i < helpers.size(); ++i) {
754 std::vector<QuantLib::ext::shared_ptr<BlackCalibrationHelper>> h(1, helpers[i]);
755 calibrate(h, method, endCriteria, constraint, weights, MoveParameter(assetType, 0, idx, i));
756 }
757 update();
758}
std::vector< bool > MoveParameter(const AssetType t, const Size param, const Size index, const Size i)
virtual void calibrate(const std::vector< QuantLib::ext::shared_ptr< CalibrationHelper > > &, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >(), const std::vector< bool > &fixParameters=std::vector< bool >())
Calibrate to a set of market instruments (usually caps/swaptions)
+ Here is the call graph for this function:

◆ calibrateBsVolatilitiesGlobal()

void calibrateBsVolatilitiesGlobal ( const AssetType assetType,
const Size  aIdx,
const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  helpers,
OptimizationMethod method,
const EndCriteria &  endCriteria,
const Constraint constraint = Constraint(),
const std::vector< Real > &  weights = std::vector<Real>() 
)

calibrate eq/fx/com volatilities globally to a set of eq/fx/com options

Definition at line 760 of file crossassetmodel.cpp.

763 {
764 QL_REQUIRE(assetType == CrossAssetModel::AssetType::FX || assetType == CrossAssetModel::AssetType::EQ,
765 "Unsupported AssetType for BS calibration");
766 calibrate(helpers, method, endCriteria, constraint, weights, MoveParameter(assetType, 0, aIdx, Null<Size>()));
767 update();
768}
Size aIdx(const AssetType t, const Size i, const Size offset=0) const
+ Here is the call graph for this function:

◆ calibrateInfDkVolatilitiesIterative()

void calibrateInfDkVolatilitiesIterative ( const Size  index,
const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  helpers,
OptimizationMethod method,
const EndCriteria &  endCriteria,
const Constraint constraint = Constraint(),
const std::vector< Real > &  weights = std::vector<Real>() 
)

calibrate infdk volatilities to a sequence of cpi options with expiry times equal to step times in the parametrization

Definition at line 770 of file crossassetmodel.cpp.

772 {
773 for (Size i = 0; i < helpers.size(); ++i) {
774 std::vector<QuantLib::ext::shared_ptr<BlackCalibrationHelper>> h(1, helpers[i]);
775 calibrate(h, method, endCriteria, constraint, weights,
777 }
778 update();
779}
+ Here is the call graph for this function:

◆ calibrateInfDkReversionsIterative()

void calibrateInfDkReversionsIterative ( const Size  index,
const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  helpers,
OptimizationMethod method,
const EndCriteria &  endCriteria,
const Constraint constraint = Constraint(),
const std::vector< Real > &  weights = std::vector<Real>() 
)

calibrate infdk reversions to a sequence of cpi options with maturity times equal to step times in the parametrization

Definition at line 781 of file crossassetmodel.cpp.

783 {
784 for (Size i = 0; i < helpers.size(); ++i) {
785 std::vector<QuantLib::ext::shared_ptr<BlackCalibrationHelper>> h(1, helpers[i]);
786 calibrate(h, method, endCriteria, constraint, weights,
788 }
789 update();
790}
+ Here is the call graph for this function:

◆ calibrateInfDkVolatilitiesGlobal()

void calibrateInfDkVolatilitiesGlobal ( const Size  index,
const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  helpers,
OptimizationMethod method,
const EndCriteria &  endCriteria,
const Constraint constraint = Constraint(),
const std::vector< Real > &  weights = std::vector<Real>() 
)

calibrate infdk volatilities globally to a sequence of cpi cap/floors

Definition at line 792 of file crossassetmodel.cpp.

794 {
795 calibrate(helpers, method, endCriteria, constraint, weights,
796 MoveParameter(CrossAssetModel::AssetType::INF, 0, index, Null<Size>()));
797 update();
798}
+ Here is the call graph for this function:

◆ calibrateInfDkReversionsGlobal()

void calibrateInfDkReversionsGlobal ( const Size  index,
const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  helpers,
OptimizationMethod method,
const EndCriteria &  endCriteria,
const Constraint constraint = Constraint(),
const std::vector< Real > &  weights = std::vector<Real>() 
)

calibrate infdk reversions globally to a sequence of cpi cap/floors

Definition at line 800 of file crossassetmodel.cpp.

802 {
803 calibrate(helpers, method, endCriteria, constraint, weights,
804 MoveParameter(CrossAssetModel::AssetType::INF, 1, index, Null<Size>()));
805 update();
806}
+ Here is the call graph for this function:

◆ calibrateInfJyGlobal()

void calibrateInfJyGlobal ( QuantLib::Size  index,
const std::vector< QuantLib::ext::shared_ptr< QuantLib::CalibrationHelper > > &  helpers,
QuantLib::OptimizationMethod &  method,
const QuantLib::EndCriteria &  endCriteria,
const std::map< QuantLib::Size, bool > &  toCalibrate,
const QuantLib::Constraint &  constraint = QuantLib::Constraint(),
const std::vector< QuantLib::Real > &  weights = std::vector<QuantLib::Real>() 
)

Calibrate JY inflation parameters globally.

The parameter toCalibrate indicates which parameters of the JY inflation model that we want to calibrate. The map key should be in {0, 1, 2} where 0 indicates the real rate volatility, 1 indicates the real rate reversion and 2 indicates the inflation index volatility. The value is true if we wish to calibrate the parameter and false if we do not want to calibrate it.

Definition at line 808 of file crossassetmodel.cpp.

811 {
812
813 // Initialise the parameters to move first to get the size.
814 vector<bool> fixedParams = MoveParameter(CrossAssetModel::AssetType::INF, 0, index, Null<Size>());
815 std::fill(fixedParams.begin(), fixedParams.end(), true);
816
817 // Update fixedParams with parameters that need to be calibrated.
818 for (const auto& kv : toCalibrate) {
819 if (kv.second) {
820 vector<bool> tmp = MoveParameter(CrossAssetModel::AssetType::INF, kv.first, index, Null<Size>());
821 std::transform(fixedParams.begin(), fixedParams.end(), tmp.begin(), fixedParams.begin(),
822 std::logical_and<bool>());
823 }
824 }
825
826 // Perform the calibration
827 calibrate(helpers, method, endCriteria, constraint, weights, fixedParams);
828
829 update();
830}
+ Here is the call graph for this function:

◆ calibrateInfJyIterative()

void calibrateInfJyIterative ( QuantLib::Size  inflationModelIndex,
QuantLib::Size  parameterIndex,
const std::vector< QuantLib::ext::shared_ptr< QuantLib::CalibrationHelper > > &  helpers,
QuantLib::OptimizationMethod &  method,
const QuantLib::EndCriteria &  endCriteria,
const QuantLib::Constraint &  constraint = QuantLib::Constraint(),
const std::vector< QuantLib::Real > &  weights = std::vector<QuantLib::Real>() 
)

Calibrate a single JY inflation parameter iteratively.

Calibrate one of real rate volatility, real rate reversion or inflation index volatility. The parameterIndex indicates the parameter that should be calibrated where 0 indicates the real rate volatility, 1 indicates the real rate reversion and 2 indicates the inflation index volatility.

Definition at line 832 of file crossassetmodel.cpp.

835 {
836
837 for (Size i = 0; i < helpers.size(); ++i) {
838 vector<QuantLib::ext::shared_ptr<CalibrationHelper>> h(1, helpers[i]);
839 calibrate(h, method, endCriteria, constraint, weights,
841 }
842
843 update();
844}
Size pIdx(const AssetType t, const Size i, const Size offset=0) const
+ Here is the call graph for this function:

◆ calibrateCrLgm1fVolatilitiesIterative()

void calibrateCrLgm1fVolatilitiesIterative ( const Size  index,
const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  helpers,
OptimizationMethod method,
const EndCriteria &  endCriteria,
const Constraint constraint = Constraint(),
const std::vector< Real > &  weights = std::vector<Real>() 
)

calibrate crlgm1f volatilities to a sequence of cds options with expiry times equal to step times in the parametrization

Definition at line 846 of file crossassetmodel.cpp.

848 {
849 for (Size i = 0; i < helpers.size(); ++i) {
850 std::vector<QuantLib::ext::shared_ptr<BlackCalibrationHelper>> h(1, helpers[i]);
851 calibrate(h, method, endCriteria, constraint, weights,
853 }
854 update();
855}
+ Here is the call graph for this function:

◆ calibrateCrLgm1fReversionsIterative()

void calibrateCrLgm1fReversionsIterative ( const Size  index,
const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  helpers,
OptimizationMethod method,
const EndCriteria &  endCriteria,
const Constraint constraint = Constraint(),
const std::vector< Real > &  weights = std::vector<Real>() 
)

calibrate crlgm1f reversions to a sequence of cds options with maturity times equal to step times in the parametrization

Definition at line 857 of file crossassetmodel.cpp.

859 {
860 for (Size i = 0; i < helpers.size(); ++i) {
861 std::vector<QuantLib::ext::shared_ptr<BlackCalibrationHelper>> h(1, helpers[i]);
862 calibrate(h, method, endCriteria, constraint, weights,
864 }
865 update();
866}
+ Here is the call graph for this function:

◆ MoveParameter()

std::vector< bool > MoveParameter ( const AssetType  t,
const Size  param,
const Size  index,
const Size  i 
)

Definition at line 1062 of file crossassetmodel.cpp.

1062 {
1063 QL_REQUIRE(param == Null<Size>() || param < arguments(t, index), "parameter for " << t << " at " << index << " ("
1064 << param << ") out of bounds 0..."
1065 << arguments(t, index) - 1);
1066 std::vector<bool> res(0);
1073 return res;
1074}
Size arguments(const AssetType t, const Size i) const
void appendToFixedParameterVector(const AssetType t, const AssetType v, const Size param, const Size index, const Size i, std::vector< bool > &res)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ arguments()

Size arguments ( const AssetType  t,
const Size  i 
) const
protected

number of arguments for a component

Definition at line 194 of file crossassetmodel.cpp.

194 {
195 QL_REQUIRE(numArguments_[(Size)t].size() > i,
196 "CrossAssetModel::arguments(): asset class " << t << ", component " << i << " not known.");
197 return numArguments_[(Size)t][i];
198}
std::vector< std::vector< Size > > numArguments_
+ Here is the caller graph for this function:

◆ aIdx()

Size aIdx ( const AssetType  t,
const Size  i,
const Size  offset = 0 
) const
protected

index of component in the arguments vector, by offset

Definition at line 237 of file crossassetmodel.cpp.

237 {
238 QL_REQUIRE(offset < arguments(t, i), "a-offset (" << offset << ") for asset class " << t << " and index " << i
239 << " must be in 0..." << arguments(t, i) - 1);
240 QL_REQUIRE(aIdx_[(Size)t].size() > i,
241 "CrossAssetModel::aIdx(): asset class " << t << ", component " << i << " not known.");
242 return aIdx_[(Size)t][i];
243}
std::vector< std::vector< Size > > aIdx_
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponentType()

std::pair< CrossAssetModel::AssetType, CrossAssetModel::ModelType > getComponentType ( const Size  i) const
protectedvirtual

asset and model type for given parametrization

Definition at line 299 of file crossassetmodel.cpp.

299 {
300 if (QuantLib::ext::dynamic_pointer_cast<IrHwParametrization>(p_[i]))
302 if (QuantLib::ext::dynamic_pointer_cast<IrLgm1fParametrization>(p_[i]))
304 if (QuantLib::ext::dynamic_pointer_cast<FxBsParametrization>(p_[i]))
306 if (QuantLib::ext::dynamic_pointer_cast<InfDkParametrization>(p_[i]))
308 if (QuantLib::ext::dynamic_pointer_cast<InfJyParameterization>(p_[i]))
310 if (QuantLib::ext::dynamic_pointer_cast<CrLgm1fParametrization>(p_[i]))
312 if (QuantLib::ext::dynamic_pointer_cast<CrCirppParametrization>(p_[i]))
314 if (QuantLib::ext::dynamic_pointer_cast<EqBsParametrization>(p_[i]))
316 if (QuantLib::ext::dynamic_pointer_cast<CommoditySchwartzParametrization>(p_[i]))
318 if (QuantLib::ext::dynamic_pointer_cast<CrStateParametrization>(p_[i]))
320 QL_FAIL("parametrization " << i << " has unknown type");
321}
+ Here is the caller graph for this function:

◆ getNumberOfParameters()

Size getNumberOfParameters ( const Size  i) const
protectedvirtual

number of parameters for given parametrization

Definition at line 323 of file crossassetmodel.cpp.

323{ return p_[i]->numberOfParameters(); }
+ Here is the caller graph for this function:

◆ getNumberOfBrownians()

Size getNumberOfBrownians ( const Size  i) const
protectedvirtual

number of brownians (excluding aux brownians) for given parametrization

Definition at line 325 of file crossassetmodel.cpp.

325 {
326 if (auto p = QuantLib::ext::dynamic_pointer_cast<IrHwParametrization>(p_[i])) {
327 return p->m();
328 }
329 if (QuantLib::ext::dynamic_pointer_cast<IrLgm1fParametrization>(p_[i])) {
330 return 1;
331 }
332 if (QuantLib::ext::dynamic_pointer_cast<FxBsParametrization>(p_[i]))
333 return 1;
334 if (QuantLib::ext::dynamic_pointer_cast<InfDkParametrization>(p_[i]))
335 return 1;
336 if (QuantLib::ext::dynamic_pointer_cast<InfJyParameterization>(p_[i]))
337 return 2;
338 if (QuantLib::ext::dynamic_pointer_cast<CrLgm1fParametrization>(p_[i]))
339 return 1;
340 if (QuantLib::ext::dynamic_pointer_cast<CrCirppParametrization>(p_[i]))
341 return 1;
342 if (QuantLib::ext::dynamic_pointer_cast<EqBsParametrization>(p_[i]))
343 return 1;
344 if (QuantLib::ext::dynamic_pointer_cast<CommoditySchwartzParametrization>(p_[i]))
345 return 1;
346 if (QuantLib::ext::dynamic_pointer_cast<CrStateParametrization>(p_[i]))
347 return 1;
348 QL_FAIL("parametrization " << i << " has unknown type");
349}
+ Here is the caller graph for this function:

◆ getNumberOfAuxBrownians()

Size getNumberOfAuxBrownians ( const Size  i) const
protectedvirtual

number of aux brownians for given parametrization

Definition at line 351 of file crossassetmodel.cpp.

351 {
352 if (auto p = QuantLib::ext::dynamic_pointer_cast<IrHwParametrization>(p_[i])) {
353 return HwModel(p, measure_, getHwDiscretization(discretization_), i == 0).m_aux();
354 }
355 if (auto p = QuantLib::ext::dynamic_pointer_cast<IrLgm1fParametrization>(p_[i])) {
356 return LGM(p, measure_, getLgm1fDiscretization(discretization_), i == 0).m_aux();
357 }
358 if (QuantLib::ext::dynamic_pointer_cast<FxBsParametrization>(p_[i]))
359 return 0;
360 if (QuantLib::ext::dynamic_pointer_cast<InfDkParametrization>(p_[i]))
361 return discretization_ == Discretization::Exact ? 1 : 0;
362 if (QuantLib::ext::dynamic_pointer_cast<InfJyParameterization>(p_[i]))
363 return 0;
364 if (QuantLib::ext::dynamic_pointer_cast<CrLgm1fParametrization>(p_[i]))
365 return discretization_ == Discretization::Exact ? 1 : 0;
366 if (QuantLib::ext::dynamic_pointer_cast<CrCirppParametrization>(p_[i]))
367 return 0;
368 if (QuantLib::ext::dynamic_pointer_cast<EqBsParametrization>(p_[i]))
369 return 0;
370 if (QuantLib::ext::dynamic_pointer_cast<CommoditySchwartzParametrization>(p_[i]))
371 return 0;
372 if (QuantLib::ext::dynamic_pointer_cast<CrStateParametrization>(p_[i]))
373 return 0;
374 QL_FAIL("parametrization " << i << " has unknown type");
375}
Size m_aux() const override
Definition: lgm.cpp:61
LinearGaussMarkovModel LGM
Definition: lgm.hpp:164
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNumberOfStateVariables()

Size getNumberOfStateVariables ( const Size  i) const
protectedvirtual

number of state variables for given parametrization

Definition at line 377 of file crossassetmodel.cpp.

377 {
378 if (auto p = QuantLib::ext::dynamic_pointer_cast<IrHwParametrization>(p_[i])) {
379 HwModel m(p, measure_, getHwDiscretization(discretization_), i == 0);
380 return m.n() + m.n_aux();
381 }
382 if (auto p = QuantLib::ext::dynamic_pointer_cast<IrLgm1fParametrization>(p_[i])) {
383 LGM m(p, measure_, getLgm1fDiscretization(discretization_), i == 0);
384 return m.n() + m.n_aux();
385 }
386 if (QuantLib::ext::dynamic_pointer_cast<FxBsParametrization>(p_[i]))
387 return 1;
388 if (QuantLib::ext::dynamic_pointer_cast<InfDkParametrization>(p_[i]))
389 return 2;
390 if (QuantLib::ext::dynamic_pointer_cast<InfJyParameterization>(p_[i]))
391 return 2;
392 if (QuantLib::ext::dynamic_pointer_cast<CrLgm1fParametrization>(p_[i]))
393 return 2;
394 if (QuantLib::ext::dynamic_pointer_cast<CrCirppParametrization>(p_[i]))
395 return 2;
396 if (QuantLib::ext::dynamic_pointer_cast<EqBsParametrization>(p_[i]))
397 return 1;
398 if (QuantLib::ext::dynamic_pointer_cast<CommoditySchwartzParametrization>(p_[i]))
399 return 1;
400 if (QuantLib::ext::dynamic_pointer_cast<CrStateParametrization>(p_[i]))
401 return 1;
402 QL_FAIL("parametrization " << i << " has unknown type");
403}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateIndices()

void updateIndices ( const AssetType t,
const Size  i,
const Size  cIdx,
const Size  wIdx,
const Size  pIdx,
const Size  aIdx 
)
protected

helper function to init component indices

Definition at line 405 of file crossassetmodel.cpp.

406 {
407 idx_[(Size)t].push_back(i);
408 modelType_[(Size)t].push_back(getComponentType(i).second);
409 brownians_[(Size)t].push_back(getNumberOfBrownians(i));
410 auxBrownians_[(Size)t].push_back(getNumberOfAuxBrownians(i));
411 stateVariables_[(Size)t].push_back(getNumberOfStateVariables(i));
412 numArguments_[(Size)t].push_back(getNumberOfParameters(i));
413 cIdx_[(Size)t].push_back(cIdx);
414 wIdx_[(Size)t].push_back(wIdx);
415 pIdx_[(Size)t].push_back(pIdx);
416 aIdx_[(Size)t].push_back(aIdx);
418 QL_REQUIRE(wIdx_[(Size)t].back() == cIdx_[(Size)t].back(),
419 "CrossAssetModel::updateIndices(): assertion error, wIdx ("
420 << wIdx_[(Size)t].back() << ") != cIdx (" << cIdx_[(Size)t].back() << ") for asset type " << t
421 << " at index " << wIdx_[(Size)t].size() << " for Euler discretization");
422 } else {
423 QL_REQUIRE(wIdx_[(Size)t].back() == pIdx_[(Size)t].back(),
424 "CrossAssetModel::updateIndices(): assertion error, wIdx ("
425 << wIdx_[(Size)t].back() << ") != pIdx (" << pIdx_[(Size)t].back() << ") for asset type " << t
426 << " at index " << wIdx_[(Size)t].size() << " for Exact discretization");
427 }
428}
virtual Size getNumberOfStateVariables(const Size i) const
virtual Size getNumberOfAuxBrownians(const Size i) const
virtual Size getNumberOfBrownians(const Size i) const
virtual std::pair< AssetType, ModelType > getComponentType(const Size i) const
Size wIdx(const AssetType t, const Size i, const Size offset=0) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialize()

void initialize ( )
protectedvirtual

Definition at line 264 of file crossassetmodel.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initializeParametrizations()

void initializeParametrizations ( )
protectedvirtual

Definition at line 430 of file crossassetmodel.cpp.

430 {
431
432 // count the parametrizations and check their order and their support
433
434 Size i = 0, j;
435 Size cIdxTmp = 0, wIdxTmp = 0, pIdxTmp = 0, aIdxTmp = 0;
437 idx_.resize(numberOfAssetTypes);
447
448 // IR parametrizations
449
450 bool genericCtor = irModels_.empty();
451 j = 0;
452 while (i < p_.size() && getComponentType(i).first == CrossAssetModel::AssetType::IR) {
453 QL_REQUIRE(j == 0 || getComponentType(i).second == getComponentType(0).second,
454 "All IR models must be of the same type (HW, LGM can not be mixed)");
455 // initialize ir model, if generic constructor was used
456 // evaluate bank account for j = 0 (domestic process
457 if (genericCtor) {
458 if (getComponentType(i).second == ModelType::LGM1F) {
459 irModels_.push_back(QuantLib::ext::make_shared<LinearGaussMarkovModel>(
460 QuantLib::ext::dynamic_pointer_cast<IrLgm1fParametrization>(p_[i]), measure_,
461 getLgm1fDiscretization(discretization_), j == 0));
462 } else if (getComponentType(i).second == ModelType::HW) {
463 irModels_.push_back(QuantLib::ext::make_shared<HwModel>(QuantLib::ext::dynamic_pointer_cast<IrHwParametrization>(p_[i]),
464 measure_, getHwDiscretization(discretization_),
465 j == 0));
466 } else {
467 irModels_.push_back(nullptr);
468 }
469 }
470 updateIndices(CrossAssetModel::AssetType::IR, i, cIdxTmp, wIdxTmp, pIdxTmp, aIdxTmp);
471 cIdxTmp += getNumberOfBrownians(i);
473 pIdxTmp += getNumberOfStateVariables(i);
474 aIdxTmp += getNumberOfParameters(i);
475 ++j;
476 ++i;
477 }
479
480 // FX parametrizations
481
482 j = 0;
483 while (i < p_.size() && getComponentType(i).first == CrossAssetModel::AssetType::FX) {
484 fxModels_.push_back(QuantLib::ext::make_shared<FxBsModel>(QuantLib::ext::dynamic_pointer_cast<FxBsParametrization>(p_[i])));
485 updateIndices(CrossAssetModel::AssetType::FX, i, cIdxTmp, wIdxTmp, pIdxTmp, aIdxTmp);
486 cIdxTmp += getNumberOfBrownians(i);
488 pIdxTmp += getNumberOfStateVariables(i);
489 aIdxTmp += getNumberOfParameters(i);
490 ++j;
491 ++i;
492 }
494
495 QL_REQUIRE(components_[(Size)CrossAssetModel::AssetType::IR] > 0, "at least one ir parametrization must be given");
496
499 "there must be n-1 fx "
500 "for n ir parametrizations, found "
501 << components_[(Size)CrossAssetModel::AssetType::IR] << " ir and "
502 << components_[(Size)CrossAssetModel::AssetType::FX] << " fx parametrizations");
503
504 // check currencies
505
506 // without an order or a hash function on Currency this seems hard
507 // to do in a simpler way ...
508 Size uniqueCurrencies = 0;
509 std::vector<Currency> currencies;
510 for (Size i = 0; i < components_[(Size)CrossAssetModel::AssetType::IR]; ++i) {
511 Size tmp = 1;
512 for (Size j = 0; j < i; ++j) {
513 if (ir(i)->currency() == currencies[j])
514 tmp = 0;
515 }
516 uniqueCurrencies += tmp;
517 currencies.push_back(ir(i)->currency());
518 }
519 QL_REQUIRE(uniqueCurrencies == components_[(Size)CrossAssetModel::AssetType::IR], "there are duplicate currencies "
520 "in the set of ir "
521 "parametrizations");
522 for (Size i = 0; i < components_[(Size)CrossAssetModel::AssetType::FX]; ++i) {
523 QL_REQUIRE(fx(i)->currency() == ir(i + 1)->currency(),
524 "fx parametrization #" << i << " must be for currency of ir parametrization #" << (i + 1)
525 << ", but they are " << fx(i)->currency() << " and " << ir(i + 1)->currency()
526 << " respectively");
527 }
528
529 // Inf parametrizations
530
531 j = 0;
532 while (i < p_.size() && getComponentType(i).first == CrossAssetModel::AssetType::INF) {
533 updateIndices(CrossAssetModel::AssetType::INF, i, cIdxTmp, wIdxTmp, pIdxTmp, aIdxTmp);
534 cIdxTmp += getNumberOfBrownians(i);
536 pIdxTmp += getNumberOfStateVariables(i);
537 aIdxTmp += getNumberOfParameters(i);
538 ++j;
539 ++i;
540 // we do not check the currency, if not present among the model's
541 // currencies, it will throw below
542 }
544
545 // Cr parametrizations
546
547 j = 0;
548 while (i < p_.size() && getComponentType(i).first == CrossAssetModel::AssetType::CR) {
549
551 auto tmp = QuantLib::ext::dynamic_pointer_cast<CrCirppParametrization>(p_[i]);
552 QL_REQUIRE(tmp, "CrossAssetModelPlus::initializeParametrizations(): expected CrCirppParametrization");
553 crcirppModel_.push_back(QuantLib::ext::make_shared<CrCirpp>(tmp));
554 } else
555 crcirppModel_.push_back(QuantLib::ext::shared_ptr<CrCirpp>());
556
557 updateIndices(CrossAssetModel::AssetType::CR, i, cIdxTmp, wIdxTmp, pIdxTmp, aIdxTmp);
558 cIdxTmp += getNumberOfBrownians(i);
560 pIdxTmp += getNumberOfStateVariables(i);
561 aIdxTmp += getNumberOfParameters(i);
562 ++j;
563 ++i;
564 // we do not check the currency, if not present among the model's
565 // currencies, it will throw below
566 }
568
569 // Eq parametrizations
570
571 j = 0;
572 while (i < p_.size() && getComponentType(i).first == CrossAssetModel::AssetType::EQ) {
573 updateIndices(CrossAssetModel::AssetType::EQ, i, cIdxTmp, wIdxTmp, pIdxTmp, aIdxTmp);
574 cIdxTmp += getNumberOfBrownians(i);
576 pIdxTmp += getNumberOfStateVariables(i);
577 aIdxTmp += getNumberOfParameters(i);
578 ++j;
579 ++i;
580 }
582
583 // check the equity currencies to ensure they are covered by CrossAssetModel
584 for (Size i = 0; i < components(CrossAssetModel::AssetType::EQ); ++i) {
585 Currency eqCcy = eq(i)->currency();
586 try {
587 Size eqCcyIdx = ccyIndex(eqCcy);
588 QL_REQUIRE(eqCcyIdx < components_[(Size)CrossAssetModel::AssetType::IR],
589 "Invalid currency for equity " << eqbs(i)->name());
590 } catch (...) {
591 QL_FAIL("Invalid currency (" << eqCcy.code() << ") for equity " << eqbs(i)->name());
592 }
593 }
594
595 // COM parametrizations
596
597 j = 0;
598 while (i < p_.size() && getComponentType(i).first == CrossAssetModel::AssetType::COM) {
599 QuantLib::ext::shared_ptr<CommoditySchwartzParametrization> csp =
600 QuantLib::ext::dynamic_pointer_cast<CommoditySchwartzParametrization>(p_[i]);
601 QuantLib::ext::shared_ptr<CommoditySchwartzModel> csm =
602 csp ? QuantLib::ext::make_shared<CommoditySchwartzModel>(csp, getComSchwartzDiscretization(discretization_))
603 : nullptr;
604 comModels_.push_back(csm);
605 updateIndices(CrossAssetModel::AssetType::COM, i, cIdxTmp, wIdxTmp, pIdxTmp, aIdxTmp);
606 cIdxTmp += getNumberOfBrownians(i);
608 pIdxTmp += getNumberOfStateVariables(i);
609 aIdxTmp += getNumberOfParameters(i);
610 ++j;
611 ++i;
612 }
614
615 // CrState parametrizations
616
617 j = 0;
618 while (i < p_.size() && getComponentType(i).first == CrossAssetModel::AssetType::CrState) {
619 updateIndices(CrossAssetModel::AssetType::CrState, i, cIdxTmp, wIdxTmp, pIdxTmp, aIdxTmp);
620 cIdxTmp += getNumberOfBrownians(i);
622 pIdxTmp += getNumberOfStateVariables(i);
623 aIdxTmp += getNumberOfParameters(i);
624 ++j;
625 ++i;
626 }
628
629 // check the equity currencies to ensure they are covered by CrossAssetModel
630 for (Size i = 0; i < components(CrossAssetModel::AssetType::COM); ++i) {
631 Currency comCcy = com(i)->currency();
632 try {
633 Size comCcyIdx = ccyIndex(comCcy);
634 QL_REQUIRE(comCcyIdx < components_[(Size)CrossAssetModel::AssetType::IR],
635 "Invalid currency for commodity " << combs(i)->name());
636 } catch (...) {
637 QL_FAIL("Invalid currency (" << comCcy.code() << ") for commodity " << combs(i)->name());
638 }
639 }
640
641 // Summary statistics
642
643 totalDimension_ = pIdxTmp;
644 totalNumberOfBrownians_ = cIdxTmp;
645 totalNumberOfAuxBrownians_ = wIdxTmp - cIdxTmp;
646
647} // initParametrizations
static constexpr Size numberOfAssetTypes
const QuantLib::ext::shared_ptr< EqBsParametrization > eqbs(const Size ccy) const
const QuantLib::ext::shared_ptr< Parametrization > fx(const Size ccy) const
void updateIndices(const AssetType &t, const Size i, const Size cIdx, const Size wIdx, const Size pIdx, const Size aIdx)
const QuantLib::ext::shared_ptr< CommoditySchwartzParametrization > combs(const Size ccy) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initializeCorrelation()

void initializeCorrelation ( )
protectedvirtual

Definition at line 649 of file crossassetmodel.cpp.

649 {
650 Size n = brownians();
651 if (rho_.empty()) {
652 rho_ = Matrix(n, n, 0.0);
653 for (Size i = 0; i < n; ++i)
654 rho_(i, i) = 1.0;
655 return;
656 }
657 QL_REQUIRE(rho_.rows() == n && rho_.columns() == n, "correlation matrix is " << rho_.rows() << " x "
658 << rho_.columns() << " but should be "
659 << n << " x " << n);
661}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initializeArguments()

void initializeArguments ( )
protectedvirtual

Definition at line 691 of file crossassetmodel.cpp.

691 {
692 for (Size i = 0; i < p_.size(); ++i) {
693 for (Size k = 0; k < getNumberOfParameters(i); ++k) {
694 arguments_.push_back(p_[i]->parameter(k));
695 }
696 }
697}
std::vector< QuantLib::ext::shared_ptr< Parameter > > arguments_
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ finalizeArguments()

void finalizeArguments ( )
protectedvirtual

Definition at line 699 of file crossassetmodel.cpp.

699 {
701 for (Size i = 0; i < arguments_.size(); ++i) {
702 QL_REQUIRE(arguments_[i] != NULL, "unexpected error: argument " << i << " is null");
704 }
705}
+ Here is the caller graph for this function:

◆ checkModelConsistency()

void checkModelConsistency ( ) const
protectedvirtual

Definition at line 707 of file crossassetmodel.cpp.

707 {
708 QL_REQUIRE(components(CrossAssetModel::AssetType::IR) > 0, "at least one IR component must be given");
709 QL_REQUIRE(
714 p_.size(),
715 "the parametrizations must be given in the following order: ir, "
716 "fx, inf, cr, eq, com, found "
718 << " bs, " << components(CrossAssetModel::AssetType::INF) << " inf, "
720 << " eq, " << components(CrossAssetModel::AssetType::COM) << " com, "
721 << components(CrossAssetModel::AssetType::CrState) << "but there are " << p_.size()
722 << " parametrizations given in total");
723}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initDefaultIntegrator()

void initDefaultIntegrator ( )
protectedvirtual

Definition at line 273 of file crossassetmodel.cpp.

273 {
274 setIntegrationPolicy(QuantLib::ext::make_shared<SimpsonIntegral>(1.0E-8, 100), true);
275}
void setIntegrationPolicy(const QuantLib::ext::shared_ptr< Integrator > integrator, const bool usePiecewiseIntegration=true) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infV()

Real infV ( const Size  idx,
const Size  ccy,
const Time  t,
const Time  T 
) const
protected

Definition at line 985 of file crossassetmodel.cpp.

985 {
986 Real HyT = Hy(i).eval(*this, T);
987 Real HdT = irlgm1f(0)->H(T);
989 Real V;
990 if (ccy == 0) {
991 V = 0.5 * (HyT * HyT * (zetay(i).eval(*this, T) - zetay(i).eval(*this, t)) -
992 2.0 * HyT * integral(*this, P(Hy(i), ay(i), ay(i)), t, T) +
993 integral(*this, P(Hy(i), Hy(i), ay(i), ay(i)), t, T)) -
994 rhody * HdT *
995 (HyT * integral(*this, P(az(0), ay(i)), t, T) - integral(*this, P(az(0), Hy(i), ay(i)), t, T));
996 } else {
997 Real HfT = irlgm1f(ccy)->H(T);
1000 V = 0.5 * (HyT * HyT * (zetay(i).eval(*this, T) - zetay(i).eval(*this, t)) -
1001 2.0 * HyT * integral(*this, P(Hy(i), ay(i), ay(i)), t, T) +
1002 integral(*this, P(Hy(i), Hy(i), ay(i), ay(i)), t, T)) -
1003 rhody * (HyT * integral(*this, P(Hz(0), az(0), ay(i)), t, T) -
1004 integral(*this, P(Hz(0), az(0), Hy(i), ay(i)), t, T)) -
1005 rhofy * (HfT * HyT * integral(*this, P(az(ccy), ay(i)), t, T) -
1006 HfT * integral(*this, P(az(ccy), Hy(i), ay(i)), t, T) -
1007 HyT * integral(*this, P(Hz(ccy), az(ccy), ay(i)), t, T) +
1008 integral(*this, P(Hz(ccy), az(ccy), Hy(i), ay(i)), t, T)) +
1009 rhoxy * (HyT * integral(*this, P(sx(ccy - 1), ay(i)), t, T) -
1010 integral(*this, P(sx(ccy - 1), Hy(i), ay(i)), t, T));
1011 }
1012 return V;
1013}
INF alpha component. May relate to real rate portion of JY model or z component of DK model.
INF zeta component. May relate to real rate portion of JY model or z component of DK model.
Real eval(const CrossAssetModel &x, const Real t) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crV()

Real crV ( const Size  idx,
const Size  ccy,
const Time  t,
const Time  T 
) const
protected

Definition at line 1015 of file crossassetmodel.cpp.

1015 {
1016 Real HlT = Hl(i).eval(*this, T);
1017 Real HfT = Hz(ccy).eval(*this, T);
1021 return 0.5 * (HlT * HlT * (zetal(i).eval(*this, T) - zetal(i).eval(*this, t)) -
1022 2.0 * HlT * integral(*this, P(Hl(i), al(i), al(i)), t, T) +
1023 integral(*this, P(Hl(i), Hl(i), al(i), al(i)), t, T)) +
1024 rhodl * (HlT * integral(*this, P(Hz(0), az(0), al(i)), t, T) -
1025 integral(*this, P(Hz(0), az(0), Hl(i), al(i)), t, T)) +
1026 rhofl * (HfT * HlT * integral(*this, P(az(ccy), al(i)), t, T) -
1027 HfT * integral(*this, P(az(ccy), Hl(i), al(i)), t, T) -
1028 HlT * integral(*this, P(Hz(ccy), az(ccy), al(i)), t, T) +
1029 integral(*this, P(Hz(ccy), az(ccy), Hl(i), al(i)), t, T)) -
1030 rhoxl * (HlT * integral(*this, P(sx(ccy - 1), al(i)), t, T) -
1031 integral(*this, P(sx(ccy - 1), Hl(i), al(i)), t, T));
1032}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendToFixedParameterVector()

void appendToFixedParameterVector ( const AssetType  t,
const AssetType  v,
const Size  param,
const Size  index,
const Size  i,
std::vector< bool > &  res 
)
protected

Definition at line 1045 of file crossassetmodel.cpp.

1046 {
1047 for (Size j = 0; j < components(t); ++j) {
1048 for (Size k = 0; k < arguments(t, j); ++k) {
1049 std::vector<bool> tmp1(p_[idx(t, j)]->parameter(k)->size(), true);
1050 if ((param == Null<Size>() || k == param) && t == v && index == j) {
1051 for (Size ii = 0; ii < tmp1.size(); ++ii) {
1052 if (i == Null<Size>() || i == ii) {
1053 tmp1[ii] = false;
1054 }
1055 }
1056 }
1057 res.insert(res.end(), tmp1.begin(), tmp1.end());
1058 }
1059 }
1060}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ numberOfAssetTypes

constexpr Size numberOfAssetTypes = 7
staticconstexpr

Definition at line 64 of file crossassetmodel.hpp.

◆ cache_crlgm1fS_

boost::unordered_map<cache_key, std::pair<Real, Real>, cache_hasher> cache_crlgm1fS_
mutableprotected

Definition at line 477 of file crossassetmodel.hpp.

◆ cache_infdkI_

boost::unordered_map<cache_key, std::pair<Real, Real>, cache_hasher> cache_infdkI_
protected

Definition at line 477 of file crossassetmodel.hpp.

◆ components_

std::vector<Size> components_
protected

Definition at line 482 of file crossassetmodel.hpp.

◆ idx_

std::vector<std::vector<Size> > idx_
protected

Definition at line 484 of file crossassetmodel.hpp.

◆ cIdx_

std::vector<std::vector<Size> > cIdx_
protected

Definition at line 484 of file crossassetmodel.hpp.

◆ wIdx_

std::vector<std::vector<Size> > wIdx_
protected

Definition at line 484 of file crossassetmodel.hpp.

◆ pIdx_

std::vector<std::vector<Size> > pIdx_
protected

Definition at line 484 of file crossassetmodel.hpp.

◆ aIdx_

std::vector<std::vector<Size> > aIdx_
protected

Definition at line 484 of file crossassetmodel.hpp.

◆ brownians_

std::vector<std::vector<Size> > brownians_
protected

Definition at line 484 of file crossassetmodel.hpp.

◆ auxBrownians_

std::vector<std::vector<Size> > auxBrownians_
protected

Definition at line 484 of file crossassetmodel.hpp.

◆ stateVariables_

std::vector<std::vector<Size> > stateVariables_
protected

Definition at line 484 of file crossassetmodel.hpp.

◆ numArguments_

std::vector<std::vector<Size> > numArguments_
protected

Definition at line 485 of file crossassetmodel.hpp.

◆ totalDimension_

Size totalDimension_
protected

Definition at line 487 of file crossassetmodel.hpp.

◆ totalNumberOfBrownians_

Size totalNumberOfBrownians_
protected

Definition at line 487 of file crossassetmodel.hpp.

◆ totalNumberOfAuxBrownians_

Size totalNumberOfAuxBrownians_
protected

Definition at line 487 of file crossassetmodel.hpp.

◆ totalNumberOfParameters_

Size totalNumberOfParameters_
protected

Definition at line 487 of file crossassetmodel.hpp.

◆ modelType_

std::vector<std::vector<ModelType> > modelType_
protected

Definition at line 489 of file crossassetmodel.hpp.

◆ p_

std::vector<QuantLib::ext::shared_ptr<Parametrization> > p_
protected

Definition at line 491 of file crossassetmodel.hpp.

◆ irModels_

std::vector<QuantLib::ext::shared_ptr<IrModel> > irModels_
protected

Definition at line 492 of file crossassetmodel.hpp.

◆ fxModels_

std::vector<QuantLib::ext::shared_ptr<FxModel> > fxModels_
protected

Definition at line 493 of file crossassetmodel.hpp.

◆ crcirppModel_

std::vector<QuantLib::ext::shared_ptr<CrCirpp> > crcirppModel_
protected

Definition at line 494 of file crossassetmodel.hpp.

◆ comModels_

std::vector<QuantLib::ext::shared_ptr<CommodityModel> > comModels_
protected

Definition at line 495 of file crossassetmodel.hpp.

◆ rho_

Matrix rho_
protected

Definition at line 496 of file crossassetmodel.hpp.

◆ salvaging_

SalvagingAlgorithm::Type salvaging_
protected

Definition at line 497 of file crossassetmodel.hpp.

◆ measure_

IrModel::Measure measure_
protected

Definition at line 498 of file crossassetmodel.hpp.

◆ discretization_

Discretization discretization_
protected

Definition at line 499 of file crossassetmodel.hpp.

◆ integrator_

QuantLib::ext::shared_ptr<Integrator> integrator_
mutableprotected

Definition at line 500 of file crossassetmodel.hpp.

◆ stateProcess_

QuantLib::ext::shared_ptr<CrossAssetStateProcess> stateProcess_
mutableprotected

Definition at line 501 of file crossassetmodel.hpp.