Skip to content

Commit f8f0452

Browse files
pcaspersjenkins
authored andcommitted
QPR-12275 allow to overwrite or add additional fields in composite trade subcomponents
1 parent 727c417 commit f8f0452

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

OREData/ored/portfolio/compositetrade.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,15 @@ void CompositeTrade::fromXML(XMLNode* node) {
151151
trade = TradeFactory::instance().build(tradeType);
152152
trade->id() = id;
153153
trade->fromXML(nodes[i]);
154-
// if a sub trade does not have an envelope, we provide the main trade's one
155-
if (!trade->envelope().initialized())
156-
trade->envelope() = this->envelope();
154+
// the component trade's envelope is the main trade's envelope with possibly overwritten add fields
155+
Envelope env = this->envelope();
156+
for (auto const& [k, v] : trade->envelope().fullAdditionalFields())
157+
env.setAdditionalField(k,v);
158+
trade->setEnvelope(env);
157159
trades_.push_back(trade);
160+
auto tmpenv = trade->envelope();
158161
DLOG("Added Trade " << id << " (" << trade->id() << ")"
159162
<< " type:" << tradeType << " to composite trade " << this->id() << ".");
160-
std::cout << "adding trade:\n" << trade->toXMLString() << std::endl;
161163
} catch (const std::exception& e) {
162164
StructuredTradeErrorMessage(
163165
id, this->tradeType(),

0 commit comments

Comments
 (0)