Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Accumulator Class Reference

#include <ored/portfolio/accumulator.hpp>

+ Inheritance diagram for Accumulator:
+ Collaboration diagram for Accumulator:

Public Member Functions

 Accumulator (const std::string &tradeType="Accumulator")
 
 Accumulator (const std::string &currency, const std::string &fixingAmount, const TradeStrike &strike, const QuantLib::ext::shared_ptr< Underlying > &underlying, const OptionData &optionData, const std::string &startDate, const ScheduleData &observationDates, const ScheduleData &pricingDates, const ScheduleData &settlementDates, const std::string &settlementLag, const std::string &settlementCalendar, const std::string &settlementConvention, const std::vector< RangeBound > &rangeBounds, const std::vector< BarrierData > &barriers)
 
void build (const QuantLib::ext::shared_ptr< EngineFactory > &) override
 
void setIsdaTaxonomyFields () override
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (XMLDocument &doc) const override
 
- Public Member Functions inherited from ScriptedTrade
 ScriptedTrade (const std::string &tradeType="ScriptedTrade", const Envelope &env=Envelope())
 
 ScriptedTrade (const Envelope &env, const std::vector< ScriptedTradeEventData > &events, const std::vector< ScriptedTradeValueTypeData > &numbers, const std::vector< ScriptedTradeValueTypeData > &indices, const std::vector< ScriptedTradeValueTypeData > &currencies, const std::vector< ScriptedTradeValueTypeData > &daycounters, const std::map< std::string, ScriptedTradeScriptData > &script, const std::string &productTag, const std::string &tradeType="ScriptedTrade")
 
 ScriptedTrade (const Envelope &env, const std::vector< ScriptedTradeEventData > &events, const std::vector< ScriptedTradeValueTypeData > &numbers, const std::vector< ScriptedTradeValueTypeData > &indices, const std::vector< ScriptedTradeValueTypeData > &currencies, const std::vector< ScriptedTradeValueTypeData > &daycounters, const std::string &scriptName, const std::string &tradeType="ScriptedTrade")
 
void clear ()
 
void build (const QuantLib::ext::shared_ptr< EngineFactory > &) override
 
QuantLib::Real notional () const override
 Return the current notional in npvCurrency. See individual sub-classes for the precise definition. More...
 
std::string notionalCurrency () const override
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
void build (const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const PremiumData &premiumData, const Real premiumMultiplier)
 
std::map< ore::data::AssetClass, std::set< std::string > > underlyingIndices (const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
 
virtual void setIsdaTaxonomyFields ()
 
const std::vector< ScriptedTradeEventData > & events () const
 
const std::vector< ScriptedTradeValueTypeData > & numbers () const
 
const std::vector< ScriptedTradeValueTypeData > & indices () const
 
const std::vector< ScriptedTradeValueTypeData > & currencies () const
 
const std::vector< ScriptedTradeValueTypeData > & daycounters () const
 
const std::map< std::string, ScriptedTradeScriptData > & script () const
 
const std::string & productTag () const
 
const std::string & scriptName () const
 
const std::string & simmProductClass () const
 
const std::string & scheduleProductClass () const
 
const ScriptedTradeScriptDatascript (const std::string &purpose, const bool fallBackOnEmptyPurpose=true) const
 
- Public Member Functions inherited from Trade
 Trade ()
 Default constructor. More...
 
 Trade (const string &tradeType, const Envelope &env=Envelope(), const TradeActions &ta=TradeActions())
 Base class constructor. More...
 
virtual ~Trade ()
 Default destructor. More...
 
virtual void build (const QuantLib::ext::shared_ptr< EngineFactory > &)=0
 
virtual std::map< std::string, RequiredFixings::FixingDatesfixings (const QuantLib::Date &settlementDate=QuantLib::Date()) const
 
const RequiredFixingsrequiredFixings () const
 
virtual std::map< AssetClass, std::set< std::string > > underlyingIndices (const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const
 
void reset ()
 Reset trade, clear all base class data. This does not reset accumulated timings for this trade. More...
 
void resetPricingStats (const std::size_t numberOfPricings=0, const boost::timer::nanosecond_type cumulativePricingTime=0)
 Reset accumulated timings to given values. More...
 
string & id ()
 Set the trade id. More...
 
void setEnvelope (const Envelope &envelope)
 Set the envelope with counterparty and portfolio info. More...
 
void setAdditionalData (const std::map< std::string, boost::any > &additionalData)
 
TradeActionstradeActions ()
 Set the trade actions. More...
 
const string & id () const
 
const string & tradeType () const
 
const Envelopeenvelope () const
 
const set< string > & portfolioIds () const
 
const TradeActionstradeActions () const
 
const QuantLib::ext::shared_ptr< InstrumentWrapper > & instrument () const
 
const std::vector< QuantLib::Leg > & legs () const
 
const std::vector< string > & legCurrencies () const
 
const std::vector< bool > & legPayers () const
 
const string & npvCurrency () const
 
const Date & maturity () const
 
virtual bool isExpired (const Date &d)
 
const string & issuer () const
 
template<typename T >
additionalDatum (const std::string &tag) const
 returns any additional datum. More...
 
virtual const std::map< std::string, boost::any > & additionalData () const
 returns all additional data returned by the trade once built More...
 
const std::string & sensitivityTemplate () const
 
void validate () const
 Utility to validate that everything that needs to be set in this base class is actually set. More...
 
virtual bool hasCashflows () const
 
boost::timer::nanosecond_type getCumulativePricingTime () const
 Get cumulative timing spent on pricing. More...
 
std::size_t getNumberOfPricings () const
 Get number of pricings. More...
 
- 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...
 

Inspectors

std::string currency_
 
std::string fixingAmount_
 
TradeStrike strike_
 
QuantLib::ext::shared_ptr< Underlyingunderlying_
 
OptionData optionData_
 
std::string startDate_
 
ScheduleData observationDates_
 
ScheduleData pricingDates_
 
ScheduleData settlementDates_
 
std::string settlementLag_
 
std::string settlementCalendar_
 
std::string settlementConvention_
 
bool nakedOption_ = false
 
bool dailyFixingAmount_ = false
 
std::vector< RangeBoundrangeBounds_
 
std::vector< BarrierDatabarriers_
 
const std::string & name () const
 
void initIndices ()
 

Additional Inherited Members

- Protected Member Functions inherited from Trade
Date addPremiums (std::vector< QuantLib::ext::shared_ptr< Instrument > > &instruments, std::vector< Real > &multipliers, const Real tradeMultiplier, const PremiumData &premiumData, const Real premiumMultiplier, const Currency &tradeCurrency, const QuantLib::ext::shared_ptr< EngineFactory > &factory, const string &configuration)
 
void setLegBasedAdditionalData (const Size legNo, Size resultLegId=Null< Size >()) const
 
void setSensitivityTemplate (const EngineBuilder &builder)
 
void setSensitivityTemplate (const std::string &id)
 
- Protected Attributes inherited from ScriptedTrade
std::vector< ScriptedTradeEventDataevents_
 
std::vector< ScriptedTradeValueTypeDatanumbers_
 
std::vector< ScriptedTradeValueTypeDataindices_
 
std::vector< ScriptedTradeValueTypeDatacurrencies_
 
std::vector< ScriptedTradeValueTypeDatadaycounters_
 
std::map< std::string, ScriptedTradeScriptDatascript_
 
std::string productTag_
 
std::string scriptName_
 
std::string simmProductClass_
 
std::string scheduleProductClass_
 
- Protected Attributes inherited from Trade
string tradeType_
 
QuantLib::ext::shared_ptr< InstrumentWrapperinstrument_
 
std::vector< QuantLib::Leg > legs_
 
std::vector< string > legCurrencies_
 
std::vector< boollegPayers_
 
string npvCurrency_
 
QuantLib::Real notional_
 
string notionalCurrency_
 
Date maturity_
 
string issuer_
 
string sensitivityTemplate_
 
bool sensitivityTemplateSet_ = false
 
std::size_t savedNumberOfPricings_ = 0
 
boost::timer::nanosecond_type savedCumulativePricingTime_ = 0
 
RequiredFixings requiredFixings_
 
std::map< std::string, boost::any > additionalData_
 

Detailed Description

Definition at line 38 of file accumulator.hpp.

Constructor & Destructor Documentation

◆ Accumulator() [1/2]

Accumulator ( const std::string &  tradeType = "Accumulator")
explicit

Definition at line 40 of file accumulator.hpp.

ScriptedTrade(const std::string &tradeType="ScriptedTrade", const Envelope &env=Envelope())
const string & tradeType() const
Definition: trade.hpp:133

◆ Accumulator() [2/2]

Accumulator ( const std::string &  currency,
const std::string &  fixingAmount,
const TradeStrike strike,
const QuantLib::ext::shared_ptr< Underlying > &  underlying,
const OptionData optionData,
const std::string &  startDate,
const ScheduleData observationDates,
const ScheduleData pricingDates,
const ScheduleData settlementDates,
const std::string &  settlementLag,
const std::string &  settlementCalendar,
const std::string &  settlementConvention,
const std::vector< RangeBound > &  rangeBounds,
const std::vector< BarrierData > &  barriers 
)

Definition at line 41 of file accumulator.hpp.

47 : currency_(currency), fixingAmount_(fixingAmount), strike_(strike), underlying_(underlying),
48 optionData_(optionData), startDate_(startDate), observationDates_(observationDates),
49 pricingDates_(pricingDates), settlementDates_(settlementDates), settlementLag_(settlementLag),
50 settlementCalendar_(settlementCalendar), settlementConvention_(settlementConvention),
51 rangeBounds_(rangeBounds), barriers_(barriers) {
53 }
std::string settlementConvention_
Definition: accumulator.hpp:72
ScheduleData settlementDates_
Definition: accumulator.hpp:71
QuantLib::ext::shared_ptr< Underlying > underlying_
Definition: accumulator.hpp:68
std::string settlementLag_
Definition: accumulator.hpp:72
ScheduleData observationDates_
Definition: accumulator.hpp:71
ScheduleData pricingDates_
Definition: accumulator.hpp:71
std::vector< BarrierData > barriers_
Definition: accumulator.hpp:77
std::string fixingAmount_
Definition: accumulator.hpp:66
std::string settlementCalendar_
Definition: accumulator.hpp:72
std::vector< RangeBound > rangeBounds_
Definition: accumulator.hpp:76
set< Date > pricingDates(const Date &s, const Date &e, const Calendar &pricingCalendar, bool excludeStart, bool includeEnd, bool useBusinessDays)
+ Here is the call graph for this function:

Member Function Documentation

◆ build()

void build ( const QuantLib::ext::shared_ptr< EngineFactory > &  )
overridevirtual

Build QuantLib/QuantExt instrument, link pricing engine. If build() is called multiple times, reset() should be called between these calls.

Implements Trade.

Definition at line 223 of file accumulator.cpp.

223 {
224
225 // set script parameters
226
227 clear();
228 initIndices();
229
230 enum class AccumulatorScript { Accumulator01, Accumulator02 };
231 AccumulatorScript scriptToUse;
232 if (!pricingDates_.hasData()) {
233 scriptToUse = AccumulatorScript::Accumulator01;
234 DLOG("building scripted trade wrapper using (internal) script Accumulator01");
235 } else {
236 scriptToUse = AccumulatorScript::Accumulator02;
237 DLOG("building scripted trade wrapper using (internal) script Accumulator02");
238 }
239
240 Real leverageMultiplier;
241 if (optionData_.payoffType() == "Accumulator")
242 leverageMultiplier = 1.0;
243 else if (optionData_.payoffType() == "Decumulator")
244 leverageMultiplier = -1.0;
245 else {
246 QL_FAIL("invalid payoff type, expected Accumulator or Decumulator");
247 }
248
249 if (strike_.currency().empty())
251 Real globalStrike = strike_.value();
252
253 QL_REQUIRE(scriptToUse == AccumulatorScript::Accumulator01 || globalStrike != Null<Real>(),
254 "For accumulator type 02 a global strike must be given");
255
256 std::vector<std::string> rangeUpperBounds, rangeLowerBounds, rangeLeverages, rangeStrikes;
257 for (auto const& r : rangeBounds_) {
258 rangeLowerBounds.push_back(
259 boost::lexical_cast<std::string>(r.from() == Null<Real>() ? -QL_MAX_REAL : r.from()));
260 rangeUpperBounds.push_back(boost::lexical_cast<std::string>(r.to() == Null<Real>() ? QL_MAX_REAL : r.to()));
261 rangeLeverages.push_back(
262 boost::lexical_cast<std::string>(leverageMultiplier * (r.leverage() == Null<Real>() ? 1.0 : r.leverage())));
263 if (scriptToUse == AccumulatorScript::Accumulator01) {
264 if (r.strike() != Null<Real>()) {
265 rangeStrikes.push_back(boost::lexical_cast<std::string>(r.strike()));
266 } else if (r.strikeAdjustment() != Null<Real>() && globalStrike != Null<Real>()) {
267 rangeStrikes.push_back(boost::lexical_cast<std::string>(globalStrike + r.strikeAdjustment()));
268 } else if (globalStrike != Null<Real>()) {
269 rangeStrikes.push_back(boost::lexical_cast<std::string>(globalStrike));
270 } else {
271 QL_FAIL(
272 "insufficient strike information: either a global strike or a range-specific strike must be given");
273 }
274 }
275 }
276
277 bool initPositive = false;
278 for (Size i = 0; i < rangeLeverages.size(); i++) {
279 Real rl = parseReal(rangeLeverages.at(i));
280 if (i == 0)
281 initPositive = rl >= 0.0;
282 else {
283 bool nextPositive = rl >= 0.0;
284 QL_REQUIRE(nextPositive == initPositive, "Range leverages must all have the same sign.");
285 }
286 }
287 numbers_.emplace_back("Number", "NakedOption", nakedOption_ ? "1" : "-1");
288 if (nakedOption_)
289 numbers_.emplace_back("Number", "OptionType", initPositive ? "1" : "-1");
290
291 numbers_.emplace_back("Number", "RangeLowerBounds", rangeLowerBounds);
292 numbers_.emplace_back("Number", "RangeUpperBounds", rangeUpperBounds);
293 numbers_.emplace_back("Number", "RangeLeverages", rangeLeverages);
294 if (scriptToUse == AccumulatorScript::Accumulator02) {
295 numbers_.emplace_back("Number", "DefaultRange", "1");
296 }
297
298 numbers_.emplace_back("Number", "FixingAmount", fixingAmount_);
299 numbers_.emplace_back("Number", "LongShort",
300 parsePositionType(optionData_.longShort()) == Position::Long ? "1" : "-1");
301
302 currencies_.emplace_back("Currency", "PayCcy", currency_);
303 if (scriptToUse == AccumulatorScript::Accumulator01) {
304 numbers_.emplace_back("Number", "Strike", rangeStrikes);
305 } else {
306 numbers_.emplace_back("Number", "Strike", boost::lexical_cast<std::string>(globalStrike));
307 }
308
309 if (scriptToUse == AccumulatorScript::Accumulator01) {
310 events_.emplace_back("FixingDates", observationDates_);
312 events_.emplace_back("SettlementDates", settlementDates_);
313 } else {
314 events_.emplace_back("SettlementDates", "FixingDates", settlementLag_.empty() ? "0D" : settlementLag_,
315 settlementCalendar_.empty() ? "NullCalendar" : settlementCalendar_,
317 }
318 } else {
319 events_.emplace_back("ObservationDates", observationDates_);
320 events_.emplace_back("KnockOutSettlementDates", "ObservationDates",
321 settlementLag_.empty() ? "0D" : settlementLag_,
322 settlementCalendar_.empty() ? "NullCalendar" : settlementCalendar_,
324 events_.emplace_back("ObservationPeriodEndDates", pricingDates_);
326 events_.emplace_back("SettlementDates", settlementDates_);
327 } else {
328 events_.emplace_back("SettlementDates", "ObservationPeriodEndDates",
329 settlementLag_.empty() ? "0D" : settlementLag_,
330 settlementCalendar_.empty() ? "NullCalendar" : settlementCalendar_,
332 }
333 }
334
335 std::string knockOutLevel = boost::lexical_cast<std::string>(QL_MAX_REAL), knockOutType = "4",
336 guaranteedFixings = "0";
337 bool barrierSet = false;
338 bool americanKO = false;
339 for (auto const& b : barriers_) {
340 QL_REQUIRE(b.style().empty() || b.style() == "European" || b.style() == "American",
341 "expected barrier style American or European, got " << b.style());
342 QL_REQUIRE(b.style() != "European" || scriptToUse == AccumulatorScript::Accumulator01,
343 "European barrier style not allowed if PricingDates are given (Accumulator02 script variant)");
344 if (b.type() == "UpAndOut" && !b.levels().empty()) {
345 knockOutType = "4";
346 knockOutLevel = boost::lexical_cast<std::string>(b.levels().front().value());
347 QL_REQUIRE(!barrierSet, "multiple barrier definitions");
348 barrierSet = true;
349 americanKO = !(b.style() == "European");
350 } else if (b.type() == "DownAndOut" && !b.levels().empty()) {
351 knockOutType = "3";
352 knockOutLevel = boost::lexical_cast<std::string>(b.levels().front().value());
353 QL_REQUIRE(!barrierSet, "multiple barrier definitions");
354 barrierSet = true;
355 americanKO = !(b.style() == "European");
356 } else if (b.type() == "FixingFloor" && !b.levels().empty()) {
357 guaranteedFixings = boost::lexical_cast<std::string>(b.levels().front().value());
358 } else
359 QL_FAIL("invalid barrier definition, expected UpAndOut, DownAndOut, FixingFloor (with exactly one level)");
360 }
361
362 numbers_.emplace_back("Number", "KnockOutLevel", knockOutLevel);
363 numbers_.emplace_back("Number", "KnockOutType", knockOutType);
364
365 if (scriptToUse == AccumulatorScript::Accumulator01) {
366 QL_REQUIRE((!americanKO && !dailyFixingAmount_) || !startDate_.empty(),
367 "For american knock out or when using a daily fixing amount StartDate must be given.");
368 events_.emplace_back("StartDate", startDate_);
369 numbers_.emplace_back("Number", "AmericanKO", americanKO ? "1" : "-1");
370 numbers_.emplace_back("Number", "GuaranteedFixings", guaranteedFixings);
371 numbers_.emplace_back("Number", "DailyFixingAmount", dailyFixingAmount_ ? "1" : "-1");
372 daycounters_.emplace_back("Daycounter", "DailyFixingAmountDayCounter", "ACT/ACT.ISDA");
373
374 } else {
375 Schedule pd = makeSchedule(pricingDates_);
376 Size gf = parseInteger(guaranteedFixings);
377 QL_REQUIRE(gf <= pd.size(),
378 "guaranteed fixings (" << gf << ") > pricing dates schedule size (" << pd.size() << ")");
379 Date gpend = gf == 0 ? Date::minDate() : pd.date(gf - 1);
380 events_.emplace_back("GuaranteedPeriodEndDate", ore::data::to_string(gpend));
381 }
382
383 // set product tag
384
385 productTag_ = scriptToUse == AccumulatorScript::Accumulator01 ? "SingleAssetOptionCG({AssetClass})"
386 : "SingleAssetOptionBwd({AssetClass})";
387
388 // set script
389
390 if (scriptToUse == AccumulatorScript::Accumulator01) {
391 script_[""] = ScriptedTradeScriptData(
392 accumulator01_script, "value",
393 {{"currentNotional", "currentNotional"},
394 {"notionalCurrency", "PayCcy"},
395 {"Alive", "Alive"},
396 {"Fixing", "Fixing"}},
397 {}, {}, {ScriptedTradeScriptData::CalibrationData("Underlying", {"Strike", "KnockOutLevel"})});
398 } else {
399 script_[""] = ScriptedTradeScriptData(
400 accumulator02_script, "value",
401 {{"currentNotional", "currentNotional"},
402 {"notionalCurrency", "PayCcy"},
403 {"KnockedOut", "KnockedOut"},
404 {"Fixing", "Fixing"}},
405 {}, {}, {ScriptedTradeScriptData::CalibrationData("Underlying", {"Strike", "KnockOutLevel"})});
406 script_["FD"] = ScriptedTradeScriptData(
407 accumulator02_script_fd, "value",
408 {{"currentNotional", "currentNotional"}, {"notionalCurrency", "PayCcy"}, {"Fixing", "Fixing"}}, {}, {},
409 {ScriptedTradeScriptData::CalibrationData("Underlying", {"Strike", "KnockOutLevel"})});
410 }
411
412 // build trade
413
414 ScriptedTrade::build(factory);
415}
const string & payoffType() const
Definition: optiondata.hpp:72
const string & longShort() const
Definition: optiondata.hpp:70
bool hasData() const
Check if has any dates/rules/derived schedules.
Definition: schedule.hpp:223
std::vector< ScriptedTradeValueTypeData > daycounters_
std::vector< ScriptedTradeEventData > events_
std::vector< ScriptedTradeValueTypeData > currencies_
std::vector< ScriptedTradeValueTypeData > numbers_
std::map< std::string, ScriptedTradeScriptData > script_
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
void setCurrency(const std::string &currency)
std::string currency()
QuantLib::Real value() const
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
Definition: parsers.cpp:404
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Definition: parsers.cpp:136
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
Schedule makeSchedule(const ScheduleDates &data)
Definition: schedule.cpp:263
+ Here is the call graph for this function:

◆ setIsdaTaxonomyFields()

void setIsdaTaxonomyFields ( )
overridevirtual

Reimplemented from ScriptedTrade.

Definition at line 417 of file accumulator.cpp.

417 {
419
420 // ISDA taxonomy, asset class set in the base class build
421 // asset class set in the base class already
422 std::string assetClass = boost::any_cast<std::string>(additionalData_["isdaAssetClass"]);
423 if (assetClass == "Equity") {
424 additionalData_["isdaBaseProduct"] = string("Other");
425 additionalData_["isdaSubProduct"] = string("Price Return Basic Performance");
426 } else if (assetClass == "Commodity") {
427 // isda taxonomy missing for this class, using the same as equity
428 additionalData_["isdaBaseProduct"] = string("Other");
429 additionalData_["isdaSubProduct"] = string("Price Return Basic Performance");
430 } else if (assetClass == "Foreign Exchange") {
431 additionalData_["isdaBaseProduct"] = string("Exotic");
432 additionalData_["isdaSubProduct"] = string("Target");
433 } else {
434 WLOG("ISDA taxonomy incomplete for trade " << id());
435 }
436
437 additionalData_["isdaTransaction"] = string("");
438}
virtual void setIsdaTaxonomyFields()
std::map< std::string, boost::any > additionalData_
Definition: trade.hpp:224
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
+ Here is the call graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Reimplemented from Trade.

Definition at line 442 of file accumulator.cpp.

442 {
443 Trade::fromXML(node);
444 XMLNode* dataNode = XMLUtils::getChildNode(node, tradeType() + "Data");
445 QL_REQUIRE(dataNode, tradeType() + "Data node not found");
446 fixingAmount_ = XMLUtils::getChildValue(dataNode, "FixingAmount", true);
447 dailyFixingAmount_ = XMLUtils::getChildValueAsBool(dataNode, "DailyFixingAmount", false, false);
448
449 currency_ = XMLUtils::getChildValue(dataNode, "Currency", false);
450 strike_.fromXML(dataNode, false, false);
451
452 XMLNode* tmp = XMLUtils::getChildNode(dataNode, "Underlying");
453 if (!tmp)
454 tmp = XMLUtils::getChildNode(dataNode, "Name");
455 UnderlyingBuilder underlyingBuilder;
456 underlyingBuilder.fromXML(tmp);
457 underlying_ = underlyingBuilder.underlying();
458
459 optionData_.fromXML(XMLUtils::getChildNode(dataNode, "OptionData"));
460 startDate_ = XMLUtils::getChildValue(dataNode, "StartDate", false);
461 observationDates_.fromXML(XMLUtils::getChildNode(dataNode, "ObservationDates"));
462 if (XMLNode* n = XMLUtils::getChildNode(dataNode, "PricingDates"))
464 if (XMLNode* n = XMLUtils::getChildNode(dataNode, "SettlementDates"))
466 settlementLag_ = XMLUtils::getChildValue(dataNode, "SettlementLag", false);
467 settlementCalendar_ = XMLUtils::getChildValue(dataNode, "SettlementCalendar", false);
468 settlementConvention_ = XMLUtils::getChildValue(dataNode, "SettlementConvention", false);
469 nakedOption_ = XMLUtils::getChildValueAsBool(dataNode, "NakedOption", false, false);
470 auto rangeBoundsNode = XMLUtils::getChildNode(dataNode, "RangeBounds");
471 QL_REQUIRE(rangeBoundsNode, "No RangeBounds node");
472 auto rangeBounds = XMLUtils::getChildrenNodes(rangeBoundsNode, "RangeBound");
473 for (auto const& n : rangeBounds) {
474 rangeBounds_.push_back(RangeBound());
475 rangeBounds_.back().fromXML(n);
476 }
477 auto barriersNode = XMLUtils::getChildNode(dataNode, "Barriers");
478 QL_REQUIRE(barriersNode, "No Barriers node");
479 auto barriers = XMLUtils::getChildrenNodes(barriersNode, "BarrierData");
480 for (auto const& n : barriers) {
481 barriers_.push_back(BarrierData());
482 barriers_.back().fromXML(n);
483 }
484 initIndices();
485}
virtual void fromXML(XMLNode *node) override
Definition: optiondata.cpp:32
virtual void fromXML(XMLNode *node) override
Definition: schedule.cpp:179
virtual void fromXML(XMLNode *node) override
Definition: trade.cpp:34
void fromXML(XMLNode *node, const bool isRequired=true, const bool allowYieldStrike=false)
Definition: tradestrike.cpp:50
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
Definition: xmlutils.cpp:428
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
Definition: xmlutils.cpp:296
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Reimplemented from Trade.

Definition at line 487 of file accumulator.cpp.

487 {
488 XMLNode* node = Trade::toXML(doc);
489 XMLNode* dataNode = doc.allocNode(tradeType() + "Data");
490 XMLUtils::appendNode(node, dataNode);
491 XMLUtils::addChild(doc, dataNode, "FixingAmount", fixingAmount_);
492 XMLUtils::addChild(doc, dataNode, "DailyFixingAmount", dailyFixingAmount_);
493 XMLUtils::addChild(doc, dataNode, "Currency", currency_);
494
495 if (strike_.value() != Null<Real>()) {
496 XMLUtils::appendNode(dataNode, strike_.toXML(doc));
497 }
498
499 XMLUtils::appendNode(dataNode, underlying_->toXML(doc));
500 XMLUtils::appendNode(dataNode, optionData_.toXML(doc));
501 if (!startDate_.empty())
502 XMLUtils::addChild(doc, dataNode, "StartDate", startDate_);
503 XMLNode* tmp = observationDates_.toXML(doc);
504 XMLUtils::setNodeName(doc, tmp, "ObservationDates");
505 XMLUtils::appendNode(dataNode, tmp);
506 if (pricingDates_.hasData()) {
507 XMLNode* tmp = pricingDates_.toXML(doc);
508 XMLUtils::setNodeName(doc, tmp, "PricingDates");
509 XMLUtils::appendNode(dataNode, tmp);
510 }
512 XMLNode* tmp = settlementDates_.toXML(doc);
513 XMLUtils::setNodeName(doc, tmp, "SettlementDates");
514 XMLUtils::appendNode(dataNode, tmp);
515 }
516 if (!settlementLag_.empty())
517 XMLUtils::addChild(doc, dataNode, "SettlementLag", settlementLag_);
518 if (!settlementCalendar_.empty())
519 XMLUtils::addChild(doc, dataNode, "SettlementCalendar", settlementCalendar_);
520 if (!settlementConvention_.empty())
521 XMLUtils::addChild(doc, dataNode, "SettlementConvention", settlementConvention_);
522 XMLUtils::addChild(doc, dataNode, "NakedOption", nakedOption_);
523 XMLNode* rangeBounds = doc.allocNode("RangeBounds");
524 for (auto& n : rangeBounds_) {
525 XMLUtils::appendNode(rangeBounds, n.toXML(doc));
526 }
527 XMLUtils::appendNode(dataNode, rangeBounds);
528 XMLNode* barriers = doc.allocNode("Barriers");
529 for (auto& n : barriers_) {
530 XMLUtils::appendNode(barriers, n.toXML(doc));
531 }
532 XMLUtils::appendNode(dataNode, barriers);
533 return node;
534}
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: optiondata.cpp:86
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: schedule.cpp:198
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: trade.cpp:46
XMLNode * toXML(XMLDocument &doc) const
Definition: tradestrike.cpp:86
static void setNodeName(XMLDocument &doc, XMLNode *node, const string &name)
Definition: xmlutils.cpp:478
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:

◆ name()

const std::string & name ( ) const

Definition at line 61 of file accumulator.hpp.

61{ return underlying_->name(); }

◆ initIndices()

void initIndices ( )
private

Definition at line 440 of file accumulator.cpp.

440{ indices_.emplace_back("Index", "Underlying", scriptedIndexName(underlying_)); }
std::vector< ScriptedTradeValueTypeData > indices_
QL_DEPRECATED_ENABLE_WARNING std::string scriptedIndexName(const QuantLib::ext::shared_ptr< Underlying > &underlying)
Definition: utilities.cpp:614
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ currency_

std::string currency_
private

Definition at line 66 of file accumulator.hpp.

◆ fixingAmount_

std::string fixingAmount_
private

Definition at line 66 of file accumulator.hpp.

◆ strike_

TradeStrike strike_
private

Definition at line 67 of file accumulator.hpp.

◆ underlying_

QuantLib::ext::shared_ptr<Underlying> underlying_
private

Definition at line 68 of file accumulator.hpp.

◆ optionData_

OptionData optionData_
private

Definition at line 69 of file accumulator.hpp.

◆ startDate_

std::string startDate_
private

Definition at line 70 of file accumulator.hpp.

◆ observationDates_

ScheduleData observationDates_
private

Definition at line 71 of file accumulator.hpp.

◆ pricingDates_

ScheduleData pricingDates_
private

Definition at line 71 of file accumulator.hpp.

◆ settlementDates_

ScheduleData settlementDates_
private

Definition at line 71 of file accumulator.hpp.

◆ settlementLag_

std::string settlementLag_
private

Definition at line 72 of file accumulator.hpp.

◆ settlementCalendar_

std::string settlementCalendar_
private

Definition at line 72 of file accumulator.hpp.

◆ settlementConvention_

std::string settlementConvention_
private

Definition at line 72 of file accumulator.hpp.

◆ nakedOption_

bool nakedOption_ = false
private

Definition at line 73 of file accumulator.hpp.

◆ dailyFixingAmount_

bool dailyFixingAmount_ = false
private

Definition at line 74 of file accumulator.hpp.

◆ rangeBounds_

std::vector<RangeBound> rangeBounds_
private

Definition at line 76 of file accumulator.hpp.

◆ barriers_

std::vector<BarrierData> barriers_
private

Definition at line 77 of file accumulator.hpp.