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

#include <ored/portfolio/scriptedtrade.hpp>

+ Inheritance diagram for ScriptedTradeScriptData:
+ Collaboration diagram for ScriptedTradeScriptData:

Classes

class  CalibrationData
 
class  NewScheduleData
 

Public Member Functions

 ScriptedTradeScriptData ()
 
 ScriptedTradeScriptData (const std::string &code, const std::string &npv, const std::vector< std::pair< std::string, std::string > > &results, const std::vector< std::string > &schedulesEligibleForCoarsening, const std::vector< NewScheduleData > &newSchedules={}, const std::vector< CalibrationData > &calibrationSpec={}, const std::vector< std::string > &stickyCloseOutStates={}, const std::vector< std::string > &conditionalExpectationModelStates={})
 
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
const std::string & code () const
 
const std::string & npv () const
 
const std::vector< std::pair< std::string, std::string > > & results () const
 
const std::vector< std::string > & schedulesEligibleForCoarsening () const
 
const std::vector< NewScheduleData > & newSchedules () const
 
const std::vector< CalibrationData > & calibrationSpec () const
 
const std::vector< std::string > & stickyCloseOutStates () const
 
const std::vector< std::string > & conditionalExpectationModelStates () const
 
- 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...
 

Private Member Functions

void formatCode ()
 

Private Attributes

std::string code_
 
std::string npv_
 
std::vector< std::pair< std::string, std::string > > results_
 
std::vector< std::string > schedulesEligibleForCoarsening_
 
std::vector< NewScheduleDatanewSchedules_
 
std::vector< CalibrationDatacalibrationSpec_
 
std::vector< std::string > stickyCloseOutStates_
 
std::vector< std::string > conditionalExpectationModelStates_
 

Detailed Description

Definition at line 102 of file scriptedtrade.hpp.

Constructor & Destructor Documentation

◆ ScriptedTradeScriptData() [1/2]

Definition at line 138 of file scriptedtrade.hpp.

138{}

◆ ScriptedTradeScriptData() [2/2]

ScriptedTradeScriptData ( const std::string &  code,
const std::string &  npv,
const std::vector< std::pair< std::string, std::string > > &  results,
const std::vector< std::string > &  schedulesEligibleForCoarsening,
const std::vector< NewScheduleData > &  newSchedules = {},
const std::vector< CalibrationData > &  calibrationSpec = {},
const std::vector< std::string > &  stickyCloseOutStates = {},
const std::vector< std::string > &  conditionalExpectationModelStates = {} 
)

Definition at line 140 of file scriptedtrade.hpp.

143 {},
144 const std::vector<CalibrationData>& calibrationSpec = {},
145 const std::vector<std::string>& stickyCloseOutStates = {},
146 const std::vector<std::string>& conditionalExpectationModelStates = {})
150 formatCode();
151 }
const std::vector< std::string > & stickyCloseOutStates() const
const std::string & code() const
std::vector< std::string > conditionalExpectationModelStates_
std::vector< CalibrationData > calibrationSpec_
std::vector< NewScheduleData > newSchedules_
const std::vector< std::string > & conditionalExpectationModelStates() const
const std::string & npv() const
const std::vector< CalibrationData > & calibrationSpec() const
std::vector< std::string > schedulesEligibleForCoarsening_
std::vector< std::pair< std::string, std::string > > results_
const std::vector< NewScheduleData > & newSchedules() const
const std::vector< std::pair< std::string, std::string > > & results() const
std::vector< std::string > stickyCloseOutStates_
const std::vector< std::string > & schedulesEligibleForCoarsening() const

Member Function Documentation

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 523 of file scriptedtrade.cpp.

523 {
524 XMLUtils::checkNode(node, "Script");
525 code_ = XMLUtils::getChildValue(node, "Code", true);
526 formatCode();
527 npv_ = XMLUtils::getChildValue(node, "NPV", true);
528 std::vector<std::string> attributes;
529 std::vector<std::string> values =
530 XMLUtils::getChildrenValuesWithAttributes(node, "Results", "Result", "rename", attributes);
531 for (Size i = 0; i < values.size(); ++i) {
532 // result name is identical to script variable expect the rename attribute is filled
533 results_.push_back(std::make_pair(attributes[i].empty() ? values[i] : attributes[i], values[i]));
534 }
535 schedulesEligibleForCoarsening_ = XMLUtils::getChildrenValues(node, "ScheduleCoarsening", "EligibleSchedule");
536 if (XMLNode* ns = XMLUtils::getChildNode(node, "NewSchedules")) {
537 std::vector<XMLNode*> newSchedules = XMLUtils::getChildrenNodes(ns, "NewSchedule");
538 for (auto const& n : newSchedules) {
539 NewScheduleData tmp;
540 tmp.fromXML(n);
541 newSchedules_.push_back(tmp);
542 }
543 }
544 if (XMLNode* ns = XMLUtils::getChildNode(node, "CalibrationSpec")) {
545 std::vector<XMLNode*> calibrations = XMLUtils::getChildrenNodes(ns, "Calibration");
546 for (auto const& n : calibrations) {
547 CalibrationData tmp;
548 tmp.fromXML(n);
549 calibrationSpec_.push_back(tmp);
550 }
551 }
552 stickyCloseOutStates_ = XMLUtils::getChildrenValues(node, "StickyCloseOutStates", "StickyCloseOutState");
553 if (XMLNode* ns = XMLUtils::getChildNode(node, "ConditionalExpectation")) {
554 conditionalExpectationModelStates_ = XMLUtils::getChildrenValues(ns, "ModelStates", "ModelState", false);
555 }
556}
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
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 XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static vector< string > getChildrenValuesWithAttributes(XMLNode *node, const string &names, const string &name, const string &attrName, vector< string > &attrs, bool mandatory=false)
Definition: xmlutils.cpp:563
static vector< string > getChildrenValues(XMLNode *node, const string &names, const string &name, bool mandatory=false)
Definition: xmlutils.cpp:306
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

XMLNode * toXML ( ore::data::XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 558 of file scriptedtrade.cpp.

558 {
559 XMLNode* n = doc.allocNode("Script");
560 XMLUtils::addChildAsCdata(doc, n, "Code", code_);
561 XMLUtils::addChild(doc, n, "NPV", npv_);
562 std::vector<std::string> values, attributes;
563 for (auto const& r : results_) {
564 attributes.push_back(r.first);
565 values.push_back(r.second);
566 }
567 XMLUtils::addChildrenWithAttributes(doc, n, "Results", "Result", values, "rename", attributes);
568 XMLUtils::addChildren(doc, n, "ScheduleCoarsening", "EligibleSchedule", schedulesEligibleForCoarsening_);
569 XMLNode* newSchedules = doc.allocNode("NewSchedules");
571 for (auto& s : newSchedules_) {
572 XMLUtils::appendNode(newSchedules, s.toXML(doc));
573 }
574 XMLNode* calibrations = doc.allocNode("CalibrationSpec");
575 XMLUtils::appendNode(n, calibrations);
576 for (auto& c : calibrationSpec_) {
577 XMLUtils::appendNode(calibrations, c.toXML(doc));
578 }
579 XMLUtils::addChildren(doc, n, "StickyCloseOutStates", "StickyCloseOutState", stickyCloseOutStates_);
580 XMLNode* condExp = doc.allocNode("ConditionalExpectation");
581 XMLUtils::appendNode(n, condExp);
582 XMLUtils::addChildren(doc, condExp, "ModelStates", "ModelState", conditionalExpectationModelStates_);
583 return n;
584}
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
static void addChildrenWithAttributes(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values, const string &attrName, const vector< string > &attrs)
Definition: xmlutils.cpp:510
static void addChildren(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values)
Definition: xmlutils.cpp:502
static void addChildAsCdata(XMLDocument &doc, XMLNode *n, const string &name, const string &value)
Definition: xmlutils.cpp:202
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:

◆ code()

const std::string & code ( ) const

Definition at line 156 of file scriptedtrade.hpp.

156{ return code_; }

◆ npv()

const std::string & npv ( ) const

Definition at line 157 of file scriptedtrade.hpp.

157{ return npv_; }

◆ results()

const std::vector< std::pair< std::string, std::string > > & results ( ) const

Definition at line 159 of file scriptedtrade.hpp.

159{ return results_; }

◆ schedulesEligibleForCoarsening()

const std::vector< std::string > & schedulesEligibleForCoarsening ( ) const

Definition at line 160 of file scriptedtrade.hpp.

◆ newSchedules()

const std::vector< NewScheduleData > & newSchedules ( ) const

Definition at line 161 of file scriptedtrade.hpp.

161{ return newSchedules_; }
+ Here is the caller graph for this function:

◆ calibrationSpec()

const std::vector< CalibrationData > & calibrationSpec ( ) const

Definition at line 162 of file scriptedtrade.hpp.

162{ return calibrationSpec_; }

◆ stickyCloseOutStates()

const std::vector< std::string > & stickyCloseOutStates ( ) const

Definition at line 163 of file scriptedtrade.hpp.

163{ return stickyCloseOutStates_; }

◆ conditionalExpectationModelStates()

const std::vector< std::string > & conditionalExpectationModelStates ( ) const

Definition at line 164 of file scriptedtrade.hpp.

164 {
166 }

◆ formatCode()

void formatCode ( )
private

Definition at line 586 of file scriptedtrade.cpp.

586 {
587 // remove carriage returns (e.g. DOS uses \r\n as a line ending, but we want \n only)
588 boost::replace_all(code_, "\r", "");
589 // untabify
590 boost::replace_all(code_, "\t", " ");
591}
+ Here is the caller graph for this function:

Member Data Documentation

◆ code_

std::string code_
private

Definition at line 170 of file scriptedtrade.hpp.

◆ npv_

std::string npv_
private

Definition at line 171 of file scriptedtrade.hpp.

◆ results_

std::vector<std::pair<std::string, std::string> > results_
private

Definition at line 172 of file scriptedtrade.hpp.

◆ schedulesEligibleForCoarsening_

std::vector<std::string> schedulesEligibleForCoarsening_
private

Definition at line 173 of file scriptedtrade.hpp.

◆ newSchedules_

std::vector<NewScheduleData> newSchedules_
private

Definition at line 174 of file scriptedtrade.hpp.

◆ calibrationSpec_

std::vector<CalibrationData> calibrationSpec_
private

Definition at line 175 of file scriptedtrade.hpp.

◆ stickyCloseOutStates_

std::vector<std::string> stickyCloseOutStates_
private

Definition at line 176 of file scriptedtrade.hpp.

◆ conditionalExpectationModelStates_

std::vector<std::string> conditionalExpectationModelStates_
private

Definition at line 177 of file scriptedtrade.hpp.