455 {
458 QL_REQUIRE(innerNode,
"No " +
type() +
"ReferenceData node");
459
460
462 QL_REQUIRE(componentsNode, "No Components node");
463
466 int k = 0;
467 for (auto const n : c) {
468
471 if (id == "") {
472 id = std::to_string(k);
473 }
474
475 DLOG(
"Parsing composite trade " << this->
id() <<
" node " << k <<
" with id: " <<
id);
476
477 QuantLib::ext::shared_ptr<Trade> trade;
478 try {
479 trade = TradeFactory::instance().build(tradeType);
481 Envelope componentEnvelope;
483 componentEnvelope.fromXML(envNode);
484 }
485 Envelope env;
486
487 for (auto const& [k, v] : componentEnvelope.fullAdditionalFields()) {
488 env.setAdditionalField(k, v);
489 }
490
491 trade->setEnvelope(env);
492 trade->fromXML(n);
494 DLOG(
"Added Trade " <<
id <<
" (" << trade->id() <<
")"
495 << " type:" << tradeType << " to composite trade " << this->id() << ".");
496 k += 1;
497 } catch (const std::exception& e) {
498 StructuredTradeErrorMessage(
499 id, tradeType,
500 "Failed to build subtrade with id '" + id + "' inside composite trade: ", e.what())
501 .log();
502 }
503
504 }
505}
vector< QuantLib::ext::shared_ptr< Trade > > tradecomponents_
const std::string & id() const
const std::string & type() const
getters
void fromXML(XMLNode *node) override
static string getAttribute(XMLNode *node, const string &attrName)
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static XMLNode * getChildNode(XMLNode *n, const string &name="")
#define DLOG(text)
Logging Macro (Level = Debug)
rapidxml::xml_node< char > XMLNode