Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | List of all members
CrossAssetModelData Class Reference

Cross Asset Model Parameters. More...

#include <ored/model/crossassetmodeldata.hpp>

+ Inheritance diagram for CrossAssetModelData:
+ Collaboration diagram for CrossAssetModelData:

Classes

struct  HandleComp
 

Public Member Functions

Constructors
 CrossAssetModelData ()
 Default constructor. More...
 
 CrossAssetModelData (const vector< QuantLib::ext::shared_ptr< IrModelData > > &irConfigs, const vector< QuantLib::ext::shared_ptr< FxBsData > > &fxConfigs, const std::map< CorrelationKey, QuantLib::Handle< QuantLib::Quote > > &c, Real tolerance=1e-4, const std::string &measure="LGM", const CrossAssetModel::Discretization discretization=CrossAssetModel::Discretization::Exact)
 Detailed constructor (IR/FX only) More...
 
 CrossAssetModelData (const std::vector< QuantLib::ext::shared_ptr< IrModelData > > &irConfigs, const std::vector< QuantLib::ext::shared_ptr< FxBsData > > &fxConfigs, const std::vector< QuantLib::ext::shared_ptr< EqBsData > > &eqConfigs, const std::map< CorrelationKey, QuantLib::Handle< QuantLib::Quote > > &c, Real tolerance=1e-4, const std::string &measure="LGM", const CrossAssetModel::Discretization discretization=CrossAssetModel::Discretization::Exact)
 Detailed constructor (IR/FX/EQ only) More...
 
 CrossAssetModelData (const std::vector< QuantLib::ext::shared_ptr< IrModelData > > &irConfigs, const std::vector< QuantLib::ext::shared_ptr< FxBsData > > &fxConfigs, const std::vector< QuantLib::ext::shared_ptr< EqBsData > > &eqConfigs, const std::vector< QuantLib::ext::shared_ptr< InflationModelData > > &infConfigs, const std::vector< QuantLib::ext::shared_ptr< CrLgmData > > &crLgmConfigs, const std::vector< QuantLib::ext::shared_ptr< CrCirData > > &crCirConfigs, const std::vector< QuantLib::ext::shared_ptr< CommoditySchwartzData > > &comConfigs, const Size numberOfCreditStates, const std::map< CorrelationKey, QuantLib::Handle< QuantLib::Quote > > &c, Real tolerance=1e-4, const std::string &measure="LGM", const CrossAssetModel::Discretization discretization=CrossAssetModel::Discretization::Exact)
 Detailed constructor (all asset classes) More...
 
void clear ()
 Clear all vectors and maps. More...
 
void validate ()
 Check consistency of config vectors. More...
 
Inspectors
const string & domesticCurrency () const
 
const vector< string > & currencies () const
 
const vector< string > & equities () const
 
const vector< string > & infIndices () const
 
const vector< string > & creditNames () const
 
const vector< string > & commodities () const
 
const vector< QuantLib::ext::shared_ptr< IrModelData > > & irConfigs () const
 
const vector< QuantLib::ext::shared_ptr< FxBsData > > & fxConfigs () const
 
const vector< QuantLib::ext::shared_ptr< EqBsData > > & eqConfigs () const
 
const vector< QuantLib::ext::shared_ptr< InflationModelData > > & infConfigs () const
 
const vector< QuantLib::ext::shared_ptr< CrLgmData > > & crLgmConfigs () const
 
const vector< QuantLib::ext::shared_ptr< CrCirData > > & crCirConfigs () const
 
const vector< QuantLib::ext::shared_ptr< CommoditySchwartzData > > & comConfigs () const
 
Size numberOfCreditStates () const
 
const std::map< CorrelationKey, QuantLib::Handle< QuantLib::Quote > > & correlations () const
 
Real bootstrapTolerance () const
 
const std::string & measure () const
 
CrossAssetModel::Discretization discretization () const
 
Setters
string & domesticCurrency ()
 
vector< string > & currencies ()
 
vector< string > & equities ()
 
vector< string > & infIndices ()
 
vector< string > & creditNames ()
 
vector< string > & commodities ()
 
vector< QuantLib::ext::shared_ptr< IrModelData > > & irConfigs ()
 
vector< QuantLib::ext::shared_ptr< FxBsData > > & fxConfigs ()
 
vector< QuantLib::ext::shared_ptr< EqBsData > > & eqConfigs ()
 
vector< QuantLib::ext::shared_ptr< InflationModelData > > & infConfigs ()
 
vector< QuantLib::ext::shared_ptr< CrLgmData > > & crLgmConfigs ()
 
vector< QuantLib::ext::shared_ptr< CrCirData > > & crCirConfigs ()
 
vector< QuantLib::ext::shared_ptr< CommoditySchwartzData > > & comConfigs ()
 
void setCorrelations (const std::map< CorrelationKey, QuantLib::Handle< QuantLib::Quote > > &corrs)
 
void setCorrelations (const QuantLib::ext::shared_ptr< InstantaneousCorrelations > &corrs)
 
Real & bootstrapTolerance ()
 
std::string & measure ()
 
CrossAssetModel::Discretizationdiscretization ()
 
Serialisation
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (XMLDocument &doc) const override
 
- Public Member Functions inherited from XMLSerializable
virtual ~XMLSerializable ()
 
virtual void fromXML (XMLNode *node)=0
 
virtual XMLNodetoXML (XMLDocument &doc) const =0
 
void fromFile (const std::string &filename)
 
void toFile (const std::string &filename) const
 
void fromXMLString (const std::string &xml)
 Parse from XML string. More...
 
std::string toXMLString () const
 Parse from XML string. More...
 

Operators

string domesticCurrency_
 
vector< std::string > currencies_
 
vector< std::string > equities_
 
vector< std::string > infindices_
 
vector< std::string > creditNames_
 
vector< std::string > commodities_
 
vector< QuantLib::ext::shared_ptr< IrModelData > > irConfigs_
 
vector< QuantLib::ext::shared_ptr< FxBsData > > fxConfigs_
 
vector< QuantLib::ext::shared_ptr< EqBsData > > eqConfigs_
 
vector< QuantLib::ext::shared_ptr< InflationModelData > > infConfigs_
 
vector< QuantLib::ext::shared_ptr< CrLgmData > > crLgmConfigs_
 
vector< QuantLib::ext::shared_ptr< CrCirData > > crCirConfigs_
 
vector< QuantLib::ext::shared_ptr< CommoditySchwartzData > > comConfigs_
 
Size numberOfCreditStates_ = 0
 
QuantLib::ext::shared_ptr< InstantaneousCorrelationscorrelations_
 
Real bootstrapTolerance_
 
std::string measure_
 
CrossAssetModel::Discretization discretization_
 
bool operator== (const CrossAssetModelData &rhs)
 
bool operator!= (const CrossAssetModelData &rhs)
 
void buildIrConfigs (map< string, QuantLib::ext::shared_ptr< IrModelData > > &irMap)
 helper to convert LGM data, possibly including defaults, into an IR config vector More...
 
void buildFxConfigs (std::map< std::string, QuantLib::ext::shared_ptr< FxBsData > > &fxMap)
 helper to convert FX data, possibly including defaults, into an FX config vector More...
 
void buildEqConfigs (std::map< std::string, QuantLib::ext::shared_ptr< EqBsData > > &eqMap)
 helper to convert EQ data, possibly including defaults, into an EQ config vector More...
 
void buildInfConfigs (const std::map< std::string, QuantLib::ext::shared_ptr< InflationModelData > > &mp)
 helper to convert INF data, possibly including defaults, into an INF config vector More...
 
void buildCrConfigs (std::map< std::string, QuantLib::ext::shared_ptr< CrLgmData > > &crLgmMap, std::map< std::string, QuantLib::ext::shared_ptr< CrCirData > > &crCirMap)
 helper to convert CR LGM data, possibly including defaults, into CR config vectors More...
 
void buildComConfigs (std::map< std::string, QuantLib::ext::shared_ptr< CommoditySchwartzData > > &comMap)
 helper to convert COM data, possibly including defaulta, into a COM config vector More...
 

Detailed Description

Cross Asset Model Parameters.

CrossAssetModelData comprises the specification of how to build and calibrate the CrossAssetModel. It contains

Definition at line 115 of file crossassetmodeldata.hpp.

Constructor & Destructor Documentation

◆ CrossAssetModelData() [1/4]

Default constructor.

Definition at line 120 of file crossassetmodeldata.hpp.

120 : bootstrapTolerance_(0.0), discretization_(CrossAssetModel::Discretization::Exact) {
121 correlations_ = QuantLib::ext::make_shared<InstantaneousCorrelations>();
122 }
QuantLib::ext::shared_ptr< InstantaneousCorrelations > correlations_
CrossAssetModel::Discretization discretization_

◆ CrossAssetModelData() [2/4]

CrossAssetModelData ( const vector< QuantLib::ext::shared_ptr< IrModelData > > &  irConfigs,
const vector< QuantLib::ext::shared_ptr< FxBsData > > &  fxConfigs,
const std::map< CorrelationKey, QuantLib::Handle< QuantLib::Quote > > &  c,
Real  tolerance = 1e-4,
const std::string &  measure = "LGM",
const CrossAssetModel::Discretization  discretization = CrossAssetModel::Discretization::Exact 
)

Detailed constructor (IR/FX only)

Parameters
irConfigsVector of IR model specifications
fxConfigsVector of FX model specifications
cCorrelation map
toleranceBootstrap tolerance used in model calibration
measureChoice of probability measure
discretizationChoice of discretization

Definition at line 125 of file crossassetmodeldata.hpp.

137 : irConfigs_(irConfigs), fxConfigs_(fxConfigs), eqConfigs_(std::vector<QuantLib::ext::shared_ptr<EqBsData>>()),
139 correlations_ = QuantLib::ext::make_shared<InstantaneousCorrelations>(c);
140 domesticCurrency_ = irConfigs_[0]->ccy();
141 currencies_.clear();
142 for (Size i = 0; i < irConfigs_.size(); ++i)
143 currencies_.push_back(irConfigs_[i]->ccy());
144 validate();
145 }
const std::string & measure() const
vector< QuantLib::ext::shared_ptr< IrModelData > > irConfigs_
void validate()
Check consistency of config vectors.
CrossAssetModel::Discretization discretization() const
vector< QuantLib::ext::shared_ptr< EqBsData > > eqConfigs_
const vector< QuantLib::ext::shared_ptr< IrModelData > > & irConfigs() const
const vector< QuantLib::ext::shared_ptr< FxBsData > > & fxConfigs() const
vector< QuantLib::ext::shared_ptr< FxBsData > > fxConfigs_
+ Here is the call graph for this function:

◆ CrossAssetModelData() [3/4]

CrossAssetModelData ( const std::vector< QuantLib::ext::shared_ptr< IrModelData > > &  irConfigs,
const std::vector< QuantLib::ext::shared_ptr< FxBsData > > &  fxConfigs,
const std::vector< QuantLib::ext::shared_ptr< EqBsData > > &  eqConfigs,
const std::map< CorrelationKey, QuantLib::Handle< QuantLib::Quote > > &  c,
Real  tolerance = 1e-4,
const std::string &  measure = "LGM",
const CrossAssetModel::Discretization  discretization = CrossAssetModel::Discretization::Exact 
)

Detailed constructor (IR/FX/EQ only)

Parameters
irConfigsVector of IR model specifications
fxConfigsVector of FX model specifications
eqConfigsVector of EQ model specifications
cCorrelation map
toleranceBootstrap tolerance used in model calibration
measureChoice of probability measure
discretizationChoice of discretization

Definition at line 148 of file crossassetmodeldata.hpp.

164 correlations_ = QuantLib::ext::make_shared<InstantaneousCorrelations>(c);
165 domesticCurrency_ = irConfigs_[0]->ccy();
166 currencies_.clear();
167 for (Size i = 0; i < irConfigs_.size(); ++i)
168 currencies_.push_back(irConfigs_[i]->ccy());
169 validate();
170 }
const vector< QuantLib::ext::shared_ptr< EqBsData > > & eqConfigs() const
+ Here is the call graph for this function:

◆ CrossAssetModelData() [4/4]

CrossAssetModelData ( const std::vector< QuantLib::ext::shared_ptr< IrModelData > > &  irConfigs,
const std::vector< QuantLib::ext::shared_ptr< FxBsData > > &  fxConfigs,
const std::vector< QuantLib::ext::shared_ptr< EqBsData > > &  eqConfigs,
const std::vector< QuantLib::ext::shared_ptr< InflationModelData > > &  infConfigs,
const std::vector< QuantLib::ext::shared_ptr< CrLgmData > > &  crLgmConfigs,
const std::vector< QuantLib::ext::shared_ptr< CrCirData > > &  crCirConfigs,
const std::vector< QuantLib::ext::shared_ptr< CommoditySchwartzData > > &  comConfigs,
const Size  numberOfCreditStates,
const std::map< CorrelationKey, QuantLib::Handle< QuantLib::Quote > > &  c,
Real  tolerance = 1e-4,
const std::string &  measure = "LGM",
const CrossAssetModel::Discretization  discretization = CrossAssetModel::Discretization::Exact 
)

Detailed constructor (all asset classes)

Parameters
irConfigsVector of IR model specifications
fxConfigsVector of FX model specifications
eqConfigsVector of EQ model specifications
infConfigsVector of INF model specifications
crLgmConfigsVector of CR LGM model specifications
crCirConfigsVector of CR CIR model specifications
comConfigsVector of COM Schwartz model specifications
numberOfCreditStatesNumber of credit states
cCorrelation map
toleranceBootstrap tolerance used in model calibration
measureChoice of probability measure
discretizationChoice of discretization

Definition at line 173 of file crossassetmodeldata.hpp.

201 correlations_ = QuantLib::ext::make_shared<InstantaneousCorrelations>(c);
202 domesticCurrency_ = irConfigs_[0]->ccy();
203 currencies_.clear();
204 for (Size i = 0; i < irConfigs_.size(); ++i)
205 currencies_.push_back(irConfigs_[i]->ccy());
206 validate();
207 }
const vector< QuantLib::ext::shared_ptr< CrCirData > > & crCirConfigs() const
const vector< QuantLib::ext::shared_ptr< CrLgmData > > & crLgmConfigs() const
const vector< QuantLib::ext::shared_ptr< InflationModelData > > & infConfigs() const
const vector< QuantLib::ext::shared_ptr< CommoditySchwartzData > > & comConfigs() const
vector< QuantLib::ext::shared_ptr< CommoditySchwartzData > > comConfigs_
vector< QuantLib::ext::shared_ptr< CrLgmData > > crLgmConfigs_
vector< QuantLib::ext::shared_ptr< CrCirData > > crCirConfigs_
vector< QuantLib::ext::shared_ptr< InflationModelData > > infConfigs_
+ Here is the call graph for this function:

Member Function Documentation

◆ clear()

void clear ( )

Clear all vectors and maps.

Definition at line 201 of file crossassetmodeldata.cpp.

201 {
202 currencies_.clear();
203 equities_.clear();
204 irConfigs_.clear();
205 fxConfigs_.clear();
206 eqConfigs_.clear();
207 infConfigs_.clear();
208 crLgmConfigs_.clear();
209 crCirConfigs_.clear();
210 comConfigs_.clear();
211 correlations_->clear();
212}
+ Here is the caller graph for this function:

◆ validate()

void validate ( )

Check consistency of config vectors.

Definition at line 214 of file crossassetmodeldata.cpp.

214 {
215 QL_REQUIRE(irConfigs_.size() > 0, "no IR data provided");
216 bool useHwModel = false;
217 // All IR configs need to be either HullWhite or LGM
218 if (auto hwModelData = QuantLib::ext::dynamic_pointer_cast<HwModelData>(irConfigs_.front())) {
219 useHwModel = true;
220 }
221 for (const auto& modelData : irConfigs_) {
222 if (useHwModel) {
223 QL_REQUIRE(QuantLib::ext::dynamic_pointer_cast<HwModelData>(modelData),
224 "expect all ir models to be of hull white models");
225 } else {
226 QL_REQUIRE(QuantLib::ext::dynamic_pointer_cast<IrLgmData>(modelData), "expect all ir models to be lgm models");
227 }
228 }
229
230 QL_REQUIRE(fxConfigs_.size() == irConfigs_.size() - 1, "inconsistent number of FX data provided");
231 for (Size i = 0; i < fxConfigs_.size(); ++i)
232 QL_REQUIRE(fxConfigs_[i]->foreignCcy() == irConfigs_[i + 1]->ccy(),
233 "currency mismatch between IR and FX config vectors");
234
235 if (measure_ == "BA" && !useHwModel) {
236 // ensure that the domestic LGM has shift = 0 and scaling = 1
237 for (Size i = 0; i < irConfigs_.size(); ++i)
238 if (irConfigs_[i]->ccy() == domesticCurrency_) {
239 auto irConfig = QuantLib::ext::dynamic_pointer_cast<IrLgmData>(irConfigs_[i]);
240 QL_REQUIRE(close_enough(irConfig->scaling(), 1.0),
241 "scaling for the domestic LGM must be 1 for BA measure simulations");
242 QL_REQUIRE(close_enough(irConfig->shiftHorizon(), 0.0),
243 "shift horizon for the domestic LGM must be 0 for BA measure simulations");
244 }
245 }
246}
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:

◆ domesticCurrency() [1/2]

const string & domesticCurrency ( ) const

Definition at line 218 of file crossassetmodeldata.hpp.

218{ return domesticCurrency_; }

◆ currencies() [1/2]

const vector< string > & currencies ( ) const

Definition at line 219 of file crossassetmodeldata.hpp.

219{ return currencies_; }

◆ equities() [1/2]

const vector< string > & equities ( ) const

Definition at line 220 of file crossassetmodeldata.hpp.

220{ return equities_; }

◆ infIndices() [1/2]

const vector< string > & infIndices ( ) const

Definition at line 221 of file crossassetmodeldata.hpp.

221{ return infindices_; }

◆ creditNames() [1/2]

const vector< string > & creditNames ( ) const

Definition at line 222 of file crossassetmodeldata.hpp.

222{ return creditNames_; }

◆ commodities() [1/2]

const vector< string > & commodities ( ) const

Definition at line 223 of file crossassetmodeldata.hpp.

223{ return commodities_; }

◆ irConfigs() [1/2]

const vector< QuantLib::ext::shared_ptr< IrModelData > > & irConfigs ( ) const

Definition at line 224 of file crossassetmodeldata.hpp.

224{ return irConfigs_; }
+ Here is the caller graph for this function:

◆ fxConfigs() [1/2]

const vector< QuantLib::ext::shared_ptr< FxBsData > > & fxConfigs ( ) const

Definition at line 225 of file crossassetmodeldata.hpp.

225{ return fxConfigs_; }

◆ eqConfigs() [1/2]

const vector< QuantLib::ext::shared_ptr< EqBsData > > & eqConfigs ( ) const

Definition at line 226 of file crossassetmodeldata.hpp.

226{ return eqConfigs_; }

◆ infConfigs() [1/2]

const vector< QuantLib::ext::shared_ptr< InflationModelData > > & infConfigs ( ) const

Definition at line 227 of file crossassetmodeldata.hpp.

227{ return infConfigs_; }

◆ crLgmConfigs() [1/2]

const vector< QuantLib::ext::shared_ptr< CrLgmData > > & crLgmConfigs ( ) const

Definition at line 228 of file crossassetmodeldata.hpp.

228{ return crLgmConfigs_; }

◆ crCirConfigs() [1/2]

const vector< QuantLib::ext::shared_ptr< CrCirData > > & crCirConfigs ( ) const

Definition at line 229 of file crossassetmodeldata.hpp.

229{ return crCirConfigs_; }

◆ comConfigs() [1/2]

const vector< QuantLib::ext::shared_ptr< CommoditySchwartzData > > & comConfigs ( ) const

Definition at line 230 of file crossassetmodeldata.hpp.

230{ return comConfigs_; }

◆ numberOfCreditStates()

Size numberOfCreditStates ( ) const

Definition at line 231 of file crossassetmodeldata.hpp.

231{ return numberOfCreditStates_; }

◆ correlations()

const std::map< CorrelationKey, QuantLib::Handle< QuantLib::Quote > > & correlations ( ) const

Definition at line 232 of file crossassetmodeldata.hpp.

232 {
233 return correlations_->correlations();
234 }

◆ bootstrapTolerance() [1/2]

Real bootstrapTolerance ( ) const

Definition at line 235 of file crossassetmodeldata.hpp.

235{ return bootstrapTolerance_; }

◆ measure() [1/2]

const std::string & measure ( ) const

Definition at line 236 of file crossassetmodeldata.hpp.

236{ return measure_; }

◆ discretization() [1/2]

CrossAssetModel::Discretization discretization ( ) const

Definition at line 237 of file crossassetmodeldata.hpp.

237{ return discretization_; }

◆ domesticCurrency() [2/2]

string & domesticCurrency ( )

Definition at line 242 of file crossassetmodeldata.hpp.

242{ return domesticCurrency_; }

◆ currencies() [2/2]

vector< string > & currencies ( )

Definition at line 243 of file crossassetmodeldata.hpp.

243{ return currencies_; }

◆ equities() [2/2]

vector< string > & equities ( )

Definition at line 244 of file crossassetmodeldata.hpp.

244{ return equities_; }

◆ infIndices() [2/2]

vector< string > & infIndices ( )

Definition at line 245 of file crossassetmodeldata.hpp.

245{ return infindices_; }

◆ creditNames() [2/2]

vector< string > & creditNames ( )

Definition at line 246 of file crossassetmodeldata.hpp.

246{ return creditNames_; }

◆ commodities() [2/2]

vector< string > & commodities ( )

Definition at line 247 of file crossassetmodeldata.hpp.

247{ return commodities_; }

◆ irConfigs() [2/2]

vector< QuantLib::ext::shared_ptr< IrModelData > > & irConfigs ( )

Definition at line 248 of file crossassetmodeldata.hpp.

248{ return irConfigs_; }

◆ fxConfigs() [2/2]

vector< QuantLib::ext::shared_ptr< FxBsData > > & fxConfigs ( )

Definition at line 249 of file crossassetmodeldata.hpp.

249{ return fxConfigs_; }

◆ eqConfigs() [2/2]

vector< QuantLib::ext::shared_ptr< EqBsData > > & eqConfigs ( )

Definition at line 250 of file crossassetmodeldata.hpp.

250{ return eqConfigs_; }

◆ infConfigs() [2/2]

vector< QuantLib::ext::shared_ptr< InflationModelData > > & infConfigs ( )

Definition at line 251 of file crossassetmodeldata.hpp.

251{ return infConfigs_; }

◆ crLgmConfigs() [2/2]

vector< QuantLib::ext::shared_ptr< CrLgmData > > & crLgmConfigs ( )

Definition at line 252 of file crossassetmodeldata.hpp.

252{ return crLgmConfigs_; }

◆ crCirConfigs() [2/2]

vector< QuantLib::ext::shared_ptr< CrCirData > > & crCirConfigs ( )

Definition at line 253 of file crossassetmodeldata.hpp.

253{ return crCirConfigs_; }

◆ comConfigs() [2/2]

vector< QuantLib::ext::shared_ptr< CommoditySchwartzData > > & comConfigs ( )

Definition at line 254 of file crossassetmodeldata.hpp.

254{ return comConfigs_; }

◆ setCorrelations() [1/2]

void setCorrelations ( const std::map< CorrelationKey, QuantLib::Handle< QuantLib::Quote > > &  corrs)

Definition at line 255 of file crossassetmodeldata.hpp.

255 {
256 correlations_ = QuantLib::ext::make_shared<InstantaneousCorrelations>(corrs);
257 }

◆ setCorrelations() [2/2]

void setCorrelations ( const QuantLib::ext::shared_ptr< InstantaneousCorrelations > &  corrs)

Definition at line 258 of file crossassetmodeldata.hpp.

258{ correlations_ = corrs; }

◆ bootstrapTolerance() [2/2]

Real & bootstrapTolerance ( )

Definition at line 259 of file crossassetmodeldata.hpp.

259{ return bootstrapTolerance_; }

◆ measure() [2/2]

std::string & measure ( )

Definition at line 260 of file crossassetmodeldata.hpp.

260{ return measure_; }

◆ discretization() [2/2]

CrossAssetModel::Discretization & discretization ( )

Definition at line 261 of file crossassetmodeldata.hpp.

261{ return discretization_; }

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 253 of file crossassetmodeldata.cpp.

253 {
254 clear();
255
256 // we can read from the subnode "CrossAssetModel" of the root node "Simulation" or
257 // directly from root = CrossAssetModel. This way fromXML(toXML()) works as expected.
258 XMLNode* modelNode;
259 if (XMLUtils::getNodeName(root) == "CrossAssetModel") {
260 modelNode = root;
261 } else {
262 XMLNode* sim = XMLUtils::locateNode(root, "Simulation");
263 modelNode = XMLUtils::getChildNode(sim, "CrossAssetModel");
264 QL_REQUIRE(modelNode, "Simulation / CrossAssetModel not found, can not read cross asset model data");
265 }
266
267 std::string discString = XMLUtils::getChildValue(modelNode, "Discretization", false);
268
269 // check deprecated way of providing Discretization under Simulation/Parameters
270 if (discString.empty()) {
271 if (XMLNode* node = XMLUtils::getChildNode(root, "Parameters")) {
272 discString = XMLUtils::getChildValue(node, "Discretization", false);
273 WLOG("Simulation/Parameters/Discretization is deprecated, use Simulation/CrossAssetModel/Discretization "
274 "instead.");
275 }
276 }
277
278 // default discString to Exact if not found
279 if(discString.empty()) {
280 discString = "Exact";
281 WLOG("CrossAssetModelData: Discretization is not given. Expected this in Simulation/CrossAssetModel or in "
282 "Simulation/Parameters/Discretization (deprecated). Fall back to Exact.");
283 }
284
286
287 domesticCurrency_ = XMLUtils::getChildValue(modelNode, "DomesticCcy", true); // mandatory
288 LOG("CrossAssetModelData: domesticCcy " << domesticCurrency_);
289
290 currencies_ = XMLUtils::getChildrenValues(modelNode, "Currencies", "Currency", true);
291 for (auto ccy : currencies_) {
292 LOG("CrossAssetModelData: ccy " << ccy);
293 }
294
295 equities_ = XMLUtils::getChildrenValues(modelNode, "Equities", "Equity");
296 for (auto eq : equities_) {
297 LOG("CrossAssetModelData equity " << eq);
298 }
299
300 infindices_ = XMLUtils::getChildrenValues(modelNode, "InflationIndices", "InflationIndex");
301 for (auto inf : infindices_) {
302 LOG("CrossAssetModelData inflation index " << inf);
303 }
304
305 creditNames_ = XMLUtils::getChildrenValues(modelNode, "CreditNames", "CreditName");
306 for (auto cr : creditNames_) {
307 LOG("CrossAssetModelData credit name " << cr);
308 }
309
310 commodities_ = XMLUtils::getChildrenValues(modelNode, "Commodities", "Commodity");
311 for (auto com : commodities_) {
312 LOG("CrossAssetModelData commodity " << com);
313 }
314
315 bootstrapTolerance_ = XMLUtils::getChildValueAsDouble(modelNode, "BootstrapTolerance", true);
316 LOG("CrossAssetModelData: bootstrap tolerance = " << bootstrapTolerance_);
317
318 measure_ = XMLUtils::getChildValue(modelNode, "Measure", false);
319 LOG("CrossAssetModelData: measure = '" << measure_ << "'");
320
321 // Configure IR model components
322
323 std::map<std::string, QuantLib::ext::shared_ptr<IrModelData>> irDataMap;
324 XMLNode* irNode = XMLUtils::getChildNode(modelNode, "InterestRateModels");
325 if (irNode) {
326
327 bool hasLgmAndHwModels = XMLUtils::getChildNode(irNode, "LGM") && XMLUtils::getChildNode(irNode, "HWModel");
328
329 QL_REQUIRE(!hasLgmAndHwModels, "CrossAssetModelData: Found configuration for HullWhiteModel and LGM model, use "
330 "only one. Please check your simulation.xml");
331
332 for (XMLNode* child = XMLUtils::getChildNode(irNode, "LGM"); child;
333 child = XMLUtils::getNextSibling(child, "LGM")) {
334
335 QuantLib::ext::shared_ptr<IrLgmData> config(new IrLgmData());
336 config->fromXML(child);
337
338 for (Size i = 0; i < config->optionExpiries().size(); i++) {
339 LOG("LGM calibration swaption " << config->optionExpiries()[i] << " x " << config->optionTerms()[i]
340 << " " << config->optionStrikes()[i]);
341 }
342
343 irDataMap[config->qualifier()] = config;
344
345 LOG("CrossAssetModelData: IR config built for key " << config->qualifier());
346
347 } // end of for (XMLNode* child = XMLUtils::getChildNode(irNode, "LGM"); child;
348
349
350 for (XMLNode* child = XMLUtils::getChildNode(irNode, "HWModel"); child;
351 child = XMLUtils::getNextSibling(child, "HWModel")) {
352
353 QuantLib::ext::shared_ptr<HwModelData> config(new HwModelData());
354 config->fromXML(child);
355
356 for (Size i = 0; i < config->optionExpiries().size(); i++) {
357 LOG("LGM calibration swaption " << config->optionExpiries()[i] << " x " << config->optionTerms()[i]
358 << " " << config->optionStrikes()[i]);
359 }
360
361 irDataMap[config->qualifier()] = config;
362
363 LOG("CrossAssetModelData: HullWhite IR config built for key " << config->qualifier());
364
365 } // end of for (XMLNode* child = XMLUtils::getChildNode(irNode, "LGM"); child;
366
367 } // end of if (irNode)
368 else {
369 LOG("No IR model section found");
370 }
371
372 buildIrConfigs(irDataMap);
373
374 for (Size i = 0; i < irConfigs_.size(); i++)
375 LOG("CrossAssetModelData: IR config currency " << i << " = " << irConfigs_[i]->ccy());
376
377 // Configure FX model components
378
379 std::map<std::string, QuantLib::ext::shared_ptr<FxBsData>> fxDataMap;
380 XMLNode* fxNode = XMLUtils::getChildNode(modelNode, "ForeignExchangeModels");
381 if (fxNode) {
382 for (XMLNode* child = XMLUtils::getChildNode(fxNode, "CrossCcyLGM"); child;
383 child = XMLUtils::getNextSibling(child, "CrossCcyLGM")) {
384
385 QuantLib::ext::shared_ptr<FxBsData> config(new FxBsData());
386 config->fromXML(child);
387
388 for (Size i = 0; i < config->optionExpiries().size(); i++) {
389 LOG("CC-LGM calibration option " << config->optionExpiries()[i] << " " << config->optionStrikes()[i]);
390 }
391
392 fxDataMap[config->foreignCcy()] = config;
393
394 LOG("CrossAssetModelData: FX config built with key (foreign ccy) " << config->foreignCcy());
395 }
396 } else {
397 LOG("No FX Models section found");
398 }
399
400 buildFxConfigs(fxDataMap);
401
402 for (Size i = 0; i < fxConfigs_.size(); i++)
403 LOG("CrossAssetModelData: FX config currency " << i << " = " << fxConfigs_[i]->foreignCcy());
404
405 // Configure EQ model components
406
407 std::map<std::string, QuantLib::ext::shared_ptr<EqBsData>> eqDataMap;
408 XMLNode* eqNode = XMLUtils::getChildNode(modelNode, "EquityModels");
409 if (eqNode) {
410 for (XMLNode* child = XMLUtils::getChildNode(eqNode, "CrossAssetLGM"); child;
411 child = XMLUtils::getNextSibling(child, "CrossAssetLGM")) {
412
413 QuantLib::ext::shared_ptr<EqBsData> config(new EqBsData());
414 config->fromXML(child);
415
416 for (Size i = 0; i < config->optionExpiries().size(); i++) {
417 LOG("Cross-Asset Equity calibration option " << config->optionExpiries()[i] << " "
418 << config->optionStrikes()[i]);
419 }
420
421 eqDataMap[config->eqName()] = config;
422
423 LOG("CrossAssetModelData: Equity config built with key " << config->eqName());
424 }
425 } else {
426 LOG("No Equity Models section found");
427 }
428
429 buildEqConfigs(eqDataMap);
430
431 for (Size i = 0; i < eqConfigs_.size(); i++)
432 LOG("CrossAssetModelData: EQ config name " << i << " = " << eqConfigs_[i]->eqName());
433
434 // Read the inflation model data.
435 if (XMLNode* n = XMLUtils::getChildNode(modelNode, "InflationIndexModels")) {
436
437 map<string, QuantLib::ext::shared_ptr<InflationModelData>> mp;
438
439 // Loop over nodes and pick out any with name: LGM, DodgsonKainth or JarrowYildirim.
440 for (XMLNode* cn = XMLUtils::getChildNode(n); cn; cn = XMLUtils::getNextSibling(cn)) {
441
442 QuantLib::ext::shared_ptr<InflationModelData> imData;
443
444 string nodeName = XMLUtils::getNodeName(cn);
445 if (nodeName == "LGM" || nodeName == "DodgsonKainth") {
446 imData = QuantLib::ext::make_shared<InfDkData>();
447 } else if (nodeName == "JarrowYildirim") {
448 imData = QuantLib::ext::make_shared<InfJyData>();
449 } else {
450 WLOG("Did not recognise InflationIndexModels node with name "
451 << nodeName << " as a valid inflation index model so skipping it.");
452 continue;
453 }
454
455 const string& indexName = imData->index();
456 imData->fromXML(cn);
457 mp[indexName] = imData;
458
459 LOG("CrossAssetModelData: inflation index model data built with key " << indexName);
460 }
461
462 // Align the inflation model data with the infindices_ read in above and handle defaults
463 buildInfConfigs(mp);
464
465 // Log the index number and inflation index name for each inflation index model.
466 for (Size i = 0; i < infConfigs_.size(); i++)
467 LOG("CrossAssetModelData: INF config name " << i << " = " << infConfigs_[i]->index());
468
469 } else {
470 LOG("No InflationIndexModels node found so no inflation models configured.");
471 }
472
473 // Configure CR model components
474
475 std::map<std::string, QuantLib::ext::shared_ptr<CrLgmData>> crLgmDataMap;
476 std::map<std::string, QuantLib::ext::shared_ptr<CrCirData>> crCirDataMap;
477 XMLNode* crNode = XMLUtils::getChildNode(modelNode, "CreditModels");
478 if (crNode) {
479 for (XMLNode* child = XMLUtils::getChildNode(crNode, "LGM"); child;
480 child = XMLUtils::getNextSibling(child, "LGM")) {
481
482 QuantLib::ext::shared_ptr<CrLgmData> config(new CrLgmData());
483 config->fromXML(child);
484
485 for (Size i = 0; i < config->optionExpiries().size(); i++) {
486 LOG("LGM calibration cds option " << config->optionExpiries()[i] << " x " << config->optionTerms()[i]
487 << " " << config->optionStrikes()[i]);
488 }
489
490 crLgmDataMap[config->name()] = config;
491
492 LOG("CrossAssetModelData: CR LGM config built for key " << config->name());
493
494 } // end of for (XMLNode* child = XMLUtils::getChildNode(irNode, "LGM"); child;
495 for (XMLNode* child = XMLUtils::getChildNode(crNode, "CIR"); child;
496 child = XMLUtils::getNextSibling(child, "CIR")) {
497
498 QuantLib::ext::shared_ptr<CrCirData> config(new CrCirData());
499 config->fromXML(child);
500
501 for (Size i = 0; i < config->optionExpiries().size(); i++) {
502 LOG("CIR calibration cds option " << config->optionExpiries()[i] << " x " << config->optionTerms()[i]
503 << " " << config->optionStrikes()[i]);
504 }
505
506 crCirDataMap[config->name()] = config;
507
508 LOG("CrossAssetModelData: CR CIR config built for key " << config->name());
509
510 } // end of for (XMLNode* child = XMLUtils::getChildNode(irNode, "CIR"); child;
511 } // end of if (irNode)
512 else {
513 LOG("No CR model section found");
514 }
515
516 buildCrConfigs(crLgmDataMap, crCirDataMap);
517
518 for (Size i = 0; i < crLgmConfigs_.size(); i++)
519 LOG("CrossAssetModelData: CR LGM config name " << i << " = " << crLgmConfigs_[i]->name());
520 for (Size i = 0; i < crCirConfigs_.size(); i++)
521 LOG("CrossAssetModelData: CR CIR config name " << i << " = " << crCirConfigs_[i]->name());
522
523 // Configure COM model components
524
525 std::map<std::string, QuantLib::ext::shared_ptr<CommoditySchwartzData>> comDataMap;
526 XMLNode* comNode = XMLUtils::getChildNode(modelNode, "CommodityModels");
527 if (comNode) {
528 for (XMLNode* child = XMLUtils::getChildNode(comNode, "CommoditySchwartz"); child;
529 child = XMLUtils::getNextSibling(child, "CommoditySchwartz")) {
530
531 QuantLib::ext::shared_ptr<CommoditySchwartzData> config(new CommoditySchwartzData());
532 config->fromXML(child);
533
534 for (Size i = 0; i < config->optionExpiries().size(); i++) {
535 LOG("Cross-Asset Commodity calibration option " << config->optionExpiries()[i] << " "
536 << config->optionStrikes()[i]);
537 }
538
539 comDataMap[config->name()] = config;
540
541 LOG("CrossAssetModelData: Commodity config built with key " << config->name());
542 }
543 } else {
544 LOG("No Commodity Models section found");
545 }
546
547 buildComConfigs(comDataMap);
548
549 for (Size i = 0; i < comConfigs_.size(); i++)
550 LOG("CrossAssetModelData: COM config name " << i << " = " << comConfigs_[i]->name());
551
552 // Configure credit states
553
555 XMLNode* crStateNode = XMLUtils::getChildNode(modelNode, "CreditStates");
556 if(crStateNode) {
557 numberOfCreditStates_ = XMLUtils::getChildValueAsInt(crStateNode, "NumberOfFactors", true);
558 LOG("Set up " << numberOfCreditStates_ << " credit states.");
559 }
560 else {
561 LOG("No credit states section found");
562 }
563
564 // Configure correlation structure
565 LOG("CrossAssetModelData: adding correlations.");
566 correlations_ = QuantLib::ext::make_shared<InstantaneousCorrelations>();
567 correlations_->fromXML(modelNode);
568
569 validate();
570
571 LOG("CrossAssetModelData loading from XML done");
572}
void buildCrConfigs(std::map< std::string, QuantLib::ext::shared_ptr< CrLgmData > > &crLgmMap, std::map< std::string, QuantLib::ext::shared_ptr< CrCirData > > &crCirMap)
helper to convert CR LGM data, possibly including defaults, into CR config vectors
void buildFxConfigs(std::map< std::string, QuantLib::ext::shared_ptr< FxBsData > > &fxMap)
helper to convert FX data, possibly including defaults, into an FX config vector
void buildComConfigs(std::map< std::string, QuantLib::ext::shared_ptr< CommoditySchwartzData > > &comMap)
helper to convert COM data, possibly including defaulta, into a COM config vector
void buildInfConfigs(const std::map< std::string, QuantLib::ext::shared_ptr< InflationModelData > > &mp)
helper to convert INF data, possibly including defaults, into an INF config vector
void buildIrConfigs(map< string, QuantLib::ext::shared_ptr< IrModelData > > &irMap)
helper to convert LGM data, possibly including defaults, into an IR config vector
void clear()
Clear all vectors and maps.
void buildEqConfigs(std::map< std::string, QuantLib::ext::shared_ptr< EqBsData > > &eqMap)
helper to convert EQ data, possibly including defaults, into an EQ config vector
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
Definition: xmlutils.cpp:286
static XMLNode * locateNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:393
static string getNodeName(XMLNode *n)
Get and set a node's name.
Definition: xmlutils.cpp:473
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static int getChildValueAsInt(XMLNode *node, const string &name, bool mandatory=false, int defaultValue=0)
Definition: xmlutils.cpp:291
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
Definition: xmlutils.cpp:484
static vector< string > getChildrenValues(XMLNode *node, const string &names, const string &name, bool mandatory=false)
Definition: xmlutils.cpp:306
#define LOG(text)
Logging Macro (Level = Notice)
Definition: log.hpp:552
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
QuantExt::CrossAssetModel::Discretization parseDiscretization(const string &s)
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
Size size(const ValueType &v)
Definition: value.cpp:145
string name
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 776 of file crossassetmodeldata.cpp.

776 {
777
778 XMLNode* crossAssetModelNode = doc.allocNode("CrossAssetModel");
779
780 XMLUtils::addChild(doc, crossAssetModelNode, "DomesticCcy", domesticCurrency_);
781 XMLUtils::addChildren(doc, crossAssetModelNode, "Currencies", "Currency", currencies_);
782 XMLUtils::addChildren(doc, crossAssetModelNode, "Equities", "Equity", equities_);
783 XMLUtils::addChildren(doc, crossAssetModelNode, "InflationIndices", "InflationIndex", infindices_);
784 XMLUtils::addChildren(doc, crossAssetModelNode, "CreditNames", "CreditName", creditNames_);
785 XMLUtils::addChildren(doc, crossAssetModelNode, "Commodities", "Commodity", commodities_);
786 XMLUtils::addChild(doc, crossAssetModelNode, "BootstrapTolerance", bootstrapTolerance_);
787 XMLUtils::addChild(doc, crossAssetModelNode, "Measure", measure_);
788 XMLUtils::addChild(doc, crossAssetModelNode, "Discretization",
789 discretization_ == CrossAssetModel::Discretization::Exact ? "Exact" : "Euler");
790
791 XMLNode* interestRateModelsNode = XMLUtils::addChild(doc, crossAssetModelNode, "InterestRateModels");
792 for (Size irConfigs_Iterator = 0; irConfigs_Iterator < irConfigs_.size(); irConfigs_Iterator++) {
793 XMLNode* lgmNode = irConfigs_[irConfigs_Iterator]->toXML(doc);
794 XMLUtils::appendNode(interestRateModelsNode, lgmNode);
795 }
796
797 XMLNode* foreignExchangeModelsNode = XMLUtils::addChild(doc, crossAssetModelNode, "ForeignExchangeModels");
798 for (Size fxConfigs_Iterator = 0; fxConfigs_Iterator < fxConfigs_.size(); fxConfigs_Iterator++) {
799 XMLNode* crossCcyLgmNode = fxConfigs_[fxConfigs_Iterator]->toXML(doc);
800 XMLUtils::appendNode(foreignExchangeModelsNode, crossCcyLgmNode);
801 }
802
803 XMLNode* eqModelsNode = XMLUtils::addChild(doc, crossAssetModelNode, "EquityModels");
804 for (Size eqConfigs_Iterator = 0; eqConfigs_Iterator < eqConfigs_.size(); eqConfigs_Iterator++) {
805 XMLNode* crossAssetEqNode = eqConfigs_[eqConfigs_Iterator]->toXML(doc);
806 XMLUtils::appendNode(eqModelsNode, crossAssetEqNode);
807 }
808
809 XMLNode* infModelsNode = XMLUtils::addChild(doc, crossAssetModelNode, "InflationIndexModels");
810 for (Size infConfigs_Iterator = 0; infConfigs_Iterator < infConfigs_.size(); infConfigs_Iterator++) {
811 XMLNode* crossAssetInfNode = infConfigs_[infConfigs_Iterator]->toXML(doc);
812 XMLUtils::appendNode(infModelsNode, crossAssetInfNode);
813 }
814
815 XMLNode* crModelsNode = XMLUtils::addChild(doc, crossAssetModelNode, "CreditModels");
816 for (Size crLgmConfigs_Iterator = 0; crLgmConfigs_Iterator < crLgmConfigs_.size(); crLgmConfigs_Iterator++) {
817 XMLNode* crossAssetCrLgmNode = crLgmConfigs_[crLgmConfigs_Iterator]->toXML(doc);
818 XMLUtils::appendNode(crModelsNode, crossAssetCrLgmNode);
819 }
820 for (Size crCirConfigs_Iterator = 0; crCirConfigs_Iterator < crCirConfigs_.size(); crCirConfigs_Iterator++) {
821 XMLNode* crossAssetCrCirNode = crCirConfigs_[crCirConfigs_Iterator]->toXML(doc);
822 XMLUtils::appendNode(crModelsNode, crossAssetCrCirNode);
823 }
824
825 XMLNode* comModelsNode = XMLUtils::addChild(doc, crossAssetModelNode, "CommodityModels");
826 for (Size comConfigs_Iterator = 0; comConfigs_Iterator < comConfigs_.size(); comConfigs_Iterator++) {
827 XMLNode* crossAssetComNode = comConfigs_[comConfigs_Iterator]->toXML(doc);
828 XMLUtils::appendNode(comModelsNode, crossAssetComNode);
829 }
830
831 XMLNode* creditStateNode = XMLUtils::addChild(doc, crossAssetModelNode, "CreditStates");
832 XMLUtils::addChild(doc, creditStateNode, "NumberOfFactors", static_cast<int>(numberOfCreditStates_));
833
834 XMLNode* instantaneousCorrelationsNode = correlations_->toXML(doc);
835 XMLUtils::appendNode(crossAssetModelNode, instantaneousCorrelationsNode);
836
837 return crossAssetModelNode;
838}
static void addChildren(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values)
Definition: xmlutils.cpp:502
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
+ Here is the call graph for this function:

◆ operator==()

bool operator== ( const CrossAssetModelData rhs)

Definition at line 131 of file crossassetmodeldata.cpp.

131 {
132
133 if (*correlations_ != *rhs.correlations_)
134 return false;
135
136 if (domesticCurrency_ != rhs.domesticCurrency_ || currencies_ != rhs.currencies_ || equities_ != rhs.equities_ ||
137 infindices_ != rhs.infindices_ || bootstrapTolerance_ != rhs.bootstrapTolerance_ ||
138 irConfigs_.size() != rhs.irConfigs_.size() || fxConfigs_.size() != rhs.fxConfigs_.size() ||
139 eqConfigs_.size() != rhs.eqConfigs_.size() || infConfigs_.size() != rhs.infConfigs_.size() ||
140 crLgmConfigs_.size() != rhs.crLgmConfigs_.size() || crCirConfigs_.size() != rhs.crCirConfigs_.size() ||
141 comConfigs_.size() != rhs.comConfigs_.size()) {
142 return false;
143 }
144
145 for (Size i = 0; i < irConfigs_.size(); i++) {
146 auto c1 = QuantLib::ext::dynamic_pointer_cast<LgmData>(irConfigs_[i]);
147 auto c2 = QuantLib::ext::dynamic_pointer_cast<LgmData>(irConfigs_[i]);
148 auto c3 = QuantLib::ext::dynamic_pointer_cast<HwModelData>(irConfigs_[i]);
149 auto c4 = QuantLib::ext::dynamic_pointer_cast<HwModelData>(irConfigs_[i]);
150 if (c1 != nullptr && c2 != nullptr) {
151 if (*c1 != *c2) {
152 return false;
153 }
154 } else if (c3 != nullptr && c4 != nullptr) {
155 if (*c3 != *c4) {
156 return false;
157 }
158 } else {
159 return false;
160 }
161 }
162
163 for (Size i = 0; i < fxConfigs_.size(); i++) {
164 if (*fxConfigs_[i] != *(rhs.fxConfigs_[i])) {
165 return false;
166 }
167 }
168
169 for (Size i = 0; i < eqConfigs_.size(); i++) {
170 if (*eqConfigs_[i] != *(rhs.eqConfigs_[i])) {
171 return false;
172 }
173 }
174
175 // Not checking inflation model data for equality. The equality operators were only written to support
176 // unit testing toXML and fromXML. Questionable if it should be done this way.
177
178 for (Size i = 0; i < crLgmConfigs_.size(); i++) {
179 if (*crLgmConfigs_[i] != *(rhs.crLgmConfigs_[i])) {
180 return false;
181 }
182 }
183
184 for (Size i = 0; i < crCirConfigs_.size(); i++) {
185 if (*crCirConfigs_[i] != *(rhs.crCirConfigs_[i])) {
186 return false;
187 }
188 }
189
190 for (Size i = 0; i < comConfigs_.size(); i++) {
191 if (*comConfigs_[i] != *(rhs.comConfigs_[i])) {
192 return false;
193 }
194 }
195
196 return true;
197}

◆ operator!=()

bool operator!= ( const CrossAssetModelData rhs)

Definition at line 199 of file crossassetmodeldata.cpp.

199{ return !(*this == rhs); }

◆ buildIrConfigs()

void buildIrConfigs ( map< string, QuantLib::ext::shared_ptr< IrModelData > > &  irMap)

helper to convert LGM data, possibly including defaults, into an IR config vector

Definition at line 574 of file crossassetmodeldata.cpp.

574 {
575 // Append IR configurations into the irConfigs vector in the order of the currencies
576 // in the currencies vector.
577 // If there is an IR configuration for any of the currencies missing, then we will
578 // look up the configuration with key "default" and use this instead. If this is
579 // not provided either we will throw an exception.
580 irConfigs_.resize(currencies_.size());
581 for (Size i = 0; i < currencies_.size(); i++) {
582 string ccy = currencies_[i];
583 std::string ccyKey;
584 for (auto const& d : irDataMap) {
585 if (d.second->ccy() == ccy) {
586 QL_REQUIRE(ccyKey.empty(), "CrossAssetModelData: duplicate ir config for ccy " << ccy);
587 ccyKey = d.first;
588 }
589 }
590 if (!ccyKey.empty())
591 irConfigs_[i] = irDataMap.at(ccyKey);
592 else { // copy from default
593 LOG("IR configuration missing for currency " << ccy << ", using default");
594 if (irDataMap.find("default") == irDataMap.end()) {
595 ALOG("Both default IR and " << ccy << " IR configuration missing");
596 QL_FAIL("Both default IR and " << ccy << " IR configuration missing");
597 }
598 if (auto def = QuantLib::ext::dynamic_pointer_cast<HwModelData>(irDataMap["default"])) {
599 irConfigs_[i] = QuantLib::ext::make_shared<HwModelData>(
600 ccy, // overwrite this and keep the others
601 def->calibrationType(), def->calibrateKappa(),
602 def->kappaType(), def->kappaTimes(), def->kappaValues(), def->calibrateSigma(), def->sigmaType(),
603 def->sigmaTimes(), def->sigmaValues(), def->optionExpiries(),
604 def->optionTerms(), def->optionStrikes());
605
606 } else if (auto def = QuantLib::ext::dynamic_pointer_cast<IrLgmData>(irDataMap["default"])) {
607 irConfigs_[i] = QuantLib::ext::make_shared<IrLgmData>(
608 ccy, // overwrite this and keep the others
609 def->calibrationType(), def->reversionType(), def->volatilityType(), def->calibrateH(),
610 def->hParamType(), def->hTimes(), def->hValues(), def->calibrateA(), def->aParamType(),
611 def->aTimes(), def->aValues(), def->shiftHorizon(), def->scaling(), def->optionExpiries(),
612 def->optionTerms(), def->optionStrikes());
613 } else {
614 QL_FAIL("Unexpected model data type,expect either HwModelData or IrLgmData");
615 }
616 }
617 LOG("CrossAssetModelData: IR config added for ccy " << irConfigs_[i]->ccy());
618 }
619}
#define ALOG(text)
Logging Macro (Level = Alert)
Definition: log.hpp:544
+ Here is the caller graph for this function:

◆ buildFxConfigs()

void buildFxConfigs ( std::map< std::string, QuantLib::ext::shared_ptr< FxBsData > > &  fxMap)

helper to convert FX data, possibly including defaults, into an FX config vector

Definition at line 621 of file crossassetmodeldata.cpp.

621 {
622 // Append FX configurations into the fxConfigs vector in the order of the foreign
623 // currencies in the currencies vector.
624 // If there is an FX configuration for any of the foreign currencies missing,
625 // then we will look up the configuration with key "default" and use this instead.
626 // If this is not provided either we will throw an exception.
627 for (Size i = 0; i < currencies_.size(); i++) {
628 string ccy = currencies_[i];
629 if (ccy == domesticCurrency_)
630 continue;
631 if (fxDataMap.find(ccy) != fxDataMap.end())
632 fxConfigs_.push_back(fxDataMap[ccy]);
633 else { // copy from default
634 LOG("FX configuration missing for foreign currency " << ccy << ", using default");
635 if (fxDataMap.find("default") == fxDataMap.end()) {
636 ALOG("Both default FX and " << ccy << " FX configuration missing");
637 QL_FAIL("Both default FX and " << ccy << " FX configuration missing");
638 }
639 QuantLib::ext::shared_ptr<FxBsData> def = fxDataMap["default"];
640 QuantLib::ext::shared_ptr<FxBsData> fxData = QuantLib::ext::make_shared<FxBsData>(
641 ccy, def->domesticCcy(), def->calibrationType(), def->calibrateSigma(), def->sigmaParamType(),
642 def->sigmaTimes(), def->sigmaValues(), def->optionExpiries(), def->optionStrikes());
643
644 fxConfigs_.push_back(fxData);
645 }
646 LOG("CrossAssetModelData: FX config added for foreign ccy " << ccy);
647 }
648}
+ Here is the caller graph for this function:

◆ buildEqConfigs()

void buildEqConfigs ( std::map< std::string, QuantLib::ext::shared_ptr< EqBsData > > &  eqMap)

helper to convert EQ data, possibly including defaults, into an EQ config vector

Definition at line 650 of file crossassetmodeldata.cpp.

650 {
651 // Append Eq configurations into the eqConfigs vector in the order of the equity
652 // names in the equities) vector.
653 // If there is an Eq configuration for any of the names missing,
654 // then we will look up the configuration with key "default" and use this instead.
655 // If this is not provided either we will throw an exception.
656 for (Size i = 0; i < equities_.size(); i++) {
657 string name = equities_[i];
658 if (eqDataMap.find(name) != eqDataMap.end())
659 eqConfigs_.push_back(eqDataMap[name]);
660 else { // copy from default
661 LOG("Equity configuration missing for name " << name << ", using default");
662 if (eqDataMap.find("default") == eqDataMap.end()) {
663 ALOG("Both default EQ and " << name << " EQ configuration missing");
664 QL_FAIL("Both default EQ and " << name << " EQ configuration missing");
665 }
666 QuantLib::ext::shared_ptr<EqBsData> def = eqDataMap["default"];
667 QuantLib::ext::shared_ptr<EqBsData> eqData = QuantLib::ext::make_shared<EqBsData>(
668 name, def->currency(), def->calibrationType(), def->calibrateSigma(), def->sigmaParamType(),
669 def->sigmaTimes(), def->sigmaValues(), def->optionExpiries(), def->optionStrikes());
670
671 eqConfigs_.push_back(eqData);
672 }
673 LOG("CrossAssetModelData: EQ config added for name " << name);
674 }
675}
+ Here is the caller graph for this function:

◆ buildInfConfigs()

void buildInfConfigs ( const std::map< std::string, QuantLib::ext::shared_ptr< InflationModelData > > &  mp)

helper to convert INF data, possibly including defaults, into an INF config vector

Definition at line 677 of file crossassetmodeldata.cpp.

677 {
678
679 // Append inflation model data to the infConfigs_ vector in the order of the inflation indices in the infindices_
680 // vector.
681
682 // If for any of the inflation indices in the infindices_ vector, there is no inflation model data in mp then the
683 // default inflation model data is used. The default inflation model data should be in mp under the key name
684 // "default". If it is not provided either, an exception is thrown.
685
686 for (const string& indexName : infindices_) {
687
688 auto it = mp.find(indexName);
689 if (it != mp.end()) {
690 infConfigs_.push_back(it->second);
691 } else {
692
693 LOG("Inflation index model data missing for index " << indexName << " so attempt to use default");
694
695 auto itDefault = mp.find("default");
696 QL_REQUIRE(itDefault != mp.end(),
697 "Inflation index model data missing for index " << indexName << " and for default.");
698
699 // Make a copy of the model data and add to vector.
700 QuantLib::ext::shared_ptr<InflationModelData> imData = itDefault->second;
701 if (auto dk = QuantLib::ext::dynamic_pointer_cast<InfDkData>(imData)) {
702 infConfigs_.push_back(QuantLib::ext::make_shared<InfDkData>(*dk));
703 } else if (auto jy = QuantLib::ext::dynamic_pointer_cast<InfJyData>(imData)) {
704 infConfigs_.push_back(QuantLib::ext::make_shared<InfJyData>(*jy));
705 } else {
706 QL_FAIL("Expected inflation model data to be DK or JY.");
707 }
708 }
709
710 LOG("CrossAssetModelData: INF config added for name " << indexName);
711 }
712}
+ Here is the caller graph for this function:

◆ buildCrConfigs()

void buildCrConfigs ( std::map< std::string, QuantLib::ext::shared_ptr< CrLgmData > > &  crLgmMap,
std::map< std::string, QuantLib::ext::shared_ptr< CrCirData > > &  crCirMap 
)

helper to convert CR LGM data, possibly including defaults, into CR config vectors

Definition at line 714 of file crossassetmodeldata.cpp.

715 {
716 // Append IR configurations into the irConfigs vector in the order of the currencies
717 // in the currencies vector.
718 // If there is an IR configuration for any of the currencies missing, then we will
719 // look up the configuration with key "default" and use this instead. If this is
720 // not provided either we will throw an exception.
721 crLgmConfigs_.clear();
722 crCirConfigs_.clear();
723
724 for (Size i = 0; i < creditNames_.size(); i++) {
725 string name = creditNames_[i];
726 if (crLgmDataMap.find(name) != crLgmDataMap.end()) {
727 QL_REQUIRE(crCirDataMap.find(name) == crCirDataMap.end(), "");
728 crLgmConfigs_.push_back(crLgmDataMap[name]);
729 } else if (crCirDataMap.find(name) != crCirDataMap.end()) {
730 crCirConfigs_.push_back(crCirDataMap[name]);
731 } else { // copy from LGM default, CIR default is not used
732 LOG("CR configuration missing for name " << name << ", using default");
733 if (crLgmDataMap.find("default") == crLgmDataMap.end()) {
734 ALOG("Both default CR LGM and " << name << " CR configuration missing");
735 QL_FAIL("Both default CR and " << name << " CR configuration missing");
736 }
737 QuantLib::ext::shared_ptr<CrLgmData> def = crLgmDataMap["default"];
738 crLgmConfigs_.push_back(QuantLib::ext::make_shared<CrLgmData>(
739 name, // overwrite this and keep the others
740 def->calibrationType(), def->reversionType(), def->volatilityType(), def->calibrateH(),
741 def->hParamType(), def->hTimes(), def->hValues(), def->calibrateA(), def->aParamType(), def->aTimes(),
742 def->aValues(), def->shiftHorizon(), def->scaling(), def->optionExpiries(), def->optionTerms(),
743 def->optionStrikes()));
744 }
745 LOG("CrossAssetModelData: CR config added for name " << name << " " << name);
746 }
747}
+ Here is the caller graph for this function:

◆ buildComConfigs()

void buildComConfigs ( std::map< std::string, QuantLib::ext::shared_ptr< CommoditySchwartzData > > &  comMap)

helper to convert COM data, possibly including defaulta, into a COM config vector

Definition at line 749 of file crossassetmodeldata.cpp.

749 {
750 // Append Commodity configurations into the comConfigs vector in the order of the commodity
751 // names in the commodities vector.
752 // If there is a COM configuration for any of the names missing,
753 // then we will look up the configuration with key "default" and use this instead.
754 // If this is not provided either we will throw an exception.
755 for (Size i = 0; i < commodities_.size(); i++) {
756 string name = commodities_[i];
757 if (comDataMap.find(name) != comDataMap.end())
758 comConfigs_.push_back(comDataMap[name]);
759 else { // copy from default
760 LOG("Commodity configuration missing for name " << name << ", using default");
761 if (comDataMap.find("default") == comDataMap.end()) {
762 ALOG("Both default COM and " << name << " COM configuration missing");
763 QL_FAIL("Both default COM and " << name << " COM configuration missing");
764 }
765 QuantLib::ext::shared_ptr<CommoditySchwartzData> def = comDataMap["default"];
766 QuantLib::ext::shared_ptr<CommoditySchwartzData> comData = QuantLib::ext::make_shared<CommoditySchwartzData>(
767 name, def->currency(), def->calibrationType(), def->calibrateSigma(), def->sigmaValue(),
768 def->calibrateKappa(), def->kappaValue(), def->optionExpiries(), def->optionStrikes());
769
770 comConfigs_.push_back(comData);
771 }
772 LOG("CrossAssetModelData: COM config added for name " << name);
773 }
774}
+ Here is the caller graph for this function:

Member Data Documentation

◆ domesticCurrency_

string domesticCurrency_
private

Definition at line 297 of file crossassetmodeldata.hpp.

◆ currencies_

vector<std::string> currencies_
private

Definition at line 298 of file crossassetmodeldata.hpp.

◆ equities_

vector<std::string> equities_
private

Definition at line 299 of file crossassetmodeldata.hpp.

◆ infindices_

vector<std::string> infindices_
private

Definition at line 300 of file crossassetmodeldata.hpp.

◆ creditNames_

vector<std::string> creditNames_
private

Definition at line 301 of file crossassetmodeldata.hpp.

◆ commodities_

vector<std::string> commodities_
private

Definition at line 302 of file crossassetmodeldata.hpp.

◆ irConfigs_

vector<QuantLib::ext::shared_ptr<IrModelData> > irConfigs_
private

Definition at line 303 of file crossassetmodeldata.hpp.

◆ fxConfigs_

vector<QuantLib::ext::shared_ptr<FxBsData> > fxConfigs_
private

Definition at line 304 of file crossassetmodeldata.hpp.

◆ eqConfigs_

vector<QuantLib::ext::shared_ptr<EqBsData> > eqConfigs_
private

Definition at line 305 of file crossassetmodeldata.hpp.

◆ infConfigs_

vector<QuantLib::ext::shared_ptr<InflationModelData> > infConfigs_
private

Definition at line 306 of file crossassetmodeldata.hpp.

◆ crLgmConfigs_

vector<QuantLib::ext::shared_ptr<CrLgmData> > crLgmConfigs_
private

Definition at line 307 of file crossassetmodeldata.hpp.

◆ crCirConfigs_

vector<QuantLib::ext::shared_ptr<CrCirData> > crCirConfigs_
private

Definition at line 308 of file crossassetmodeldata.hpp.

◆ comConfigs_

vector<QuantLib::ext::shared_ptr<CommoditySchwartzData> > comConfigs_
private

Definition at line 309 of file crossassetmodeldata.hpp.

◆ numberOfCreditStates_

Size numberOfCreditStates_ = 0
private

Definition at line 310 of file crossassetmodeldata.hpp.

◆ correlations_

QuantLib::ext::shared_ptr<InstantaneousCorrelations> correlations_
private

Definition at line 312 of file crossassetmodeldata.hpp.

◆ bootstrapTolerance_

Real bootstrapTolerance_
private

Definition at line 313 of file crossassetmodeldata.hpp.

◆ measure_

std::string measure_
private

Definition at line 314 of file crossassetmodeldata.hpp.

◆ discretization_

CrossAssetModel::Discretization discretization_
private

Definition at line 315 of file crossassetmodeldata.hpp.