253 {
255
256
257
260 modelNode = root;
261 } else {
264 QL_REQUIRE(modelNode, "Simulation / CrossAssetModel not found, can not read cross asset model data");
265 }
266
268
269
270 if (discString.empty()) {
273 WLOG(
"Simulation/Parameters/Discretization is deprecated, use Simulation/CrossAssetModel/Discretization "
274 "instead.");
275 }
276 }
277
278
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
289
292 LOG(
"CrossAssetModelData: ccy " << ccy);
293 }
294
297 LOG(
"CrossAssetModelData equity " << eq);
298 }
299
302 LOG(
"CrossAssetModelData inflation index " << inf);
303 }
304
307 LOG(
"CrossAssetModelData credit name " << cr);
308 }
309
312 LOG(
"CrossAssetModelData commodity " << com);
313 }
314
317
319 LOG(
"CrossAssetModelData: measure = '" <<
measure_ <<
"'");
320
321
322
323 std::map<std::string, QuantLib::ext::shared_ptr<IrModelData>> irDataMap;
325 if (irNode) {
326
328
329 QL_REQUIRE(!hasLgmAndHwModels, "CrossAssetModelData: Found configuration for HullWhiteModel and LGM model, use "
330 "only one. Please check your simulation.xml");
331
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 }
348
349
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 }
366
367 }
368 else {
369 LOG(
"No IR model section found");
370 }
371
373
375 LOG(
"CrossAssetModelData: IR config currency " << i <<
" = " <<
irConfigs_[i]->ccy());
376
377
378
379 std::map<std::string, QuantLib::ext::shared_ptr<FxBsData>> fxDataMap;
381 if (fxNode) {
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
401
403 LOG(
"CrossAssetModelData: FX config currency " << i <<
" = " <<
fxConfigs_[i]->foreignCcy());
404
405
406
407 std::map<std::string, QuantLib::ext::shared_ptr<EqBsData>> eqDataMap;
409 if (eqNode) {
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
430
432 LOG(
"CrossAssetModelData: EQ config name " << i <<
" = " <<
eqConfigs_[i]->eqName());
433
434
436
437 map<string, QuantLib::ext::shared_ptr<InflationModelData>> mp;
438
439
441
442 QuantLib::ext::shared_ptr<InflationModelData> imData;
443
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
464
465
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
474
475 std::map<std::string, QuantLib::ext::shared_ptr<CrLgmData>> crLgmDataMap;
476 std::map<std::string, QuantLib::ext::shared_ptr<CrCirData>> crCirDataMap;
478 if (crNode) {
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 }
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 }
511 }
512 else {
513 LOG(
"No CR model section found");
514 }
515
517
522
523
524
525 std::map<std::string, QuantLib::ext::shared_ptr<CommoditySchwartzData>> comDataMap;
527 if (comNode) {
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
548
551
552
553
556 if(crStateNode) {
559 }
560 else {
561 LOG(
"No credit states section found");
562 }
563
564
565 LOG(
"CrossAssetModelData: adding correlations.");
566 correlations_ = QuantLib::ext::make_shared<InstantaneousCorrelations>();
568
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)
static XMLNode * locateNode(XMLNode *n, const string &name="")
static string getNodeName(XMLNode *n)
Get and set a node's name.
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static int getChildValueAsInt(XMLNode *node, const string &name, bool mandatory=false, int defaultValue=0)
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
static vector< string > getChildrenValues(XMLNode *node, const string &names, const string &name, bool mandatory=false)
#define LOG(text)
Logging Macro (Level = Notice)
#define WLOG(text)
Logging Macro (Level = Warning)
QuantExt::CrossAssetModel::Discretization parseDiscretization(const string &s)
rapidxml::xml_node< char > XMLNode
Size size(const ValueType &v)