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

Serializable Swaption. More...

#include <ored/portfolio/callableswap.hpp>

+ Inheritance diagram for CallableSwap:
+ Collaboration diagram for CallableSwap:

Public Member Functions

 CallableSwap ()
 Default constructor. More...
 
 CallableSwap (const ore::data::Envelope &env, const ore::data::Swap &swap, const ore::data::Swaption &swaption)
 Constructor. More...
 
void build (const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &) override
 Build QuantLib/QuantExt instrument, link pricing engine. More...
 
Inspectors
const ore::data::Swapswap () const
 
const ore::data::Swaptionswaption () 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
 
virtual QuantLib::Real notional () const
 Return the current notional in npvCurrency. See individual sub-classes for the precise definition. More...
 
virtual string notionalCurrency () 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...
 
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...
 

Serialisation

ore::data::Swap swap_
 
ore::data::Swaption swaption_
 
virtual void fromXML (ore::data::XMLNode *node) override
 
virtual ore::data::XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
const std::map< std::string, boost::any > & additionalData () const override
 returns all additional data returned by the trade once built More...
 

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 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

Serializable Swaption.

Definition at line 36 of file callableswap.hpp.

Constructor & Destructor Documentation

◆ CallableSwap() [1/2]

Default constructor.

Definition at line 39 of file callableswap.hpp.

39: ore::data::Trade("CallableSwap") {}
Trade base class.
Definition: trade.hpp:55

◆ CallableSwap() [2/2]

CallableSwap ( const ore::data::Envelope env,
const ore::data::Swap swap,
const ore::data::Swaption swaption 
)

Constructor.

Definition at line 41 of file callableswap.hpp.

42 : Trade("CallableSwap", env), swap_(swap), swaption_(swaption) {}
const ore::data::Swap & swap() const
const ore::data::Swaption & swaption() const
ore::data::Swaption swaption_
ore::data::Swap swap_
Trade()
Default constructor.
Definition: trade.hpp:59

Member Function Documentation

◆ build()

void build ( const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &  )
override

Build QuantLib/QuantExt instrument, link pricing engine.

Definition at line 30 of file callableswap.cpp.

30 {
31 LOG("Building CallableSwap " << id());
32 swap_.reset();
34 // we need to do set the id manually because it otherwise remains blank
35 swap_.id() = id() + "_Swap";
36 swap_.build(engineFactory);
37 // likewise here, and now it is essential because the engine is stored by id if the option style is Bermudan
38 swaption_.id() = id() + "_Swaption";
39 swaption_.build(engineFactory);
40
42
43 instrument_ = QuantLib::ext::make_shared<CompositeInstrumentWrapper>(
44 std::vector<QuantLib::ext::shared_ptr<InstrumentWrapper>>{swap_.instrument(), swaption_.instrument()});
45
46 legs_ = swap_.legs();
49 if (swaption_.isExercised()) {
50 legs_.insert(legs_.end(), swaption_.legs().begin(), swaption_.legs().end());
52 bool isShort = parsePositionType(swaption_.optionData().longShort()) == QuantLib::Position::Short;
53 for (auto const& p : swaption_.legPayers()) {
54 legPayers_.push_back(isShort ? !p : p);
55 }
56 }
57
62
64}
const string & longShort() const
Definition: optiondata.hpp:70
void addData(const RequiredFixings &requiredFixings)
std::string notionalCurrency() const override
Definition: swap.cpp:286
QuantLib::Real notional() const override
Return the current notional in npvCurrency. See individual sub-classes for the precise definition.
Definition: swap.cpp:267
virtual void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Build QuantLib/QuantExt instrument, link pricing engine.
Definition: swap.cpp:45
bool isExercised() const
Definition: swaption.cpp:445
const OptionData & optionData() const
Definition: swaption.hpp:49
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Definition: swaption.cpp:62
string npvCurrency_
Definition: trade.hpp:201
const std::string & sensitivityTemplate() const
Definition: trade.cpp:305
std::vector< bool > legPayers_
Definition: trade.hpp:200
std::vector< string > legCurrencies_
Definition: trade.hpp:199
const std::vector< QuantLib::Leg > & legs() const
Definition: trade.hpp:143
const Date & maturity() const
Definition: trade.hpp:157
std::vector< QuantLib::Leg > legs_
Definition: trade.hpp:198
const RequiredFixings & requiredFixings() const
Definition: trade.hpp:90
QuantLib::Real notional_
Definition: trade.hpp:202
void setSensitivityTemplate(const EngineBuilder &builder)
Definition: trade.cpp:295
const std::vector< string > & legCurrencies() const
Definition: trade.hpp:145
string & id()
Set the trade id.
Definition: trade.hpp:118
const std::vector< bool > & legPayers() const
Definition: trade.hpp:147
RequiredFixings requiredFixings_
Definition: trade.hpp:223
const QuantLib::ext::shared_ptr< InstrumentWrapper > & instrument() const
Definition: trade.hpp:141
const string & npvCurrency() const
Definition: trade.hpp:149
QuantLib::ext::shared_ptr< InstrumentWrapper > instrument_
Definition: trade.hpp:197
void reset()
Reset trade, clear all base class data. This does not reset accumulated timings for this trade.
Definition: trade.cpp:130
string notionalCurrency_
Definition: trade.hpp:203
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
Definition: parsers.cpp:404
#define LOG(text)
Logging Macro (Level = Notice)
Definition: log.hpp:552
+ Here is the call graph for this function:

◆ swap()

const ore::data::Swap & swap ( ) const

Definition at line 49 of file callableswap.hpp.

49{ return swap_; }

◆ swaption()

const ore::data::Swaption & swaption ( ) const

Definition at line 50 of file callableswap.hpp.

50{ return swaption_; }

◆ fromXML()

void fromXML ( ore::data::XMLNode node)
overridevirtual

Reimplemented from Trade.

Definition at line 68 of file callableswap.cpp.

68 {
69 Trade::fromXML(node);
70 XMLNode* swapNode = XMLUtils::getChildNode(node, "CallableSwapData");
71
72 vector<LegData> legData;
73 vector<XMLNode*> nodes = XMLUtils::getChildrenNodes(swapNode, "LegData");
74 for (Size i = 0; i < nodes.size(); i++) {
75 auto ld = QuantLib::ext::make_shared<ore::data::LegData>();
76 ld->fromXML(nodes[i]);
77 legData.push_back(*ld);
78 }
79 swap_ = ore::data::Swap(envelope(), legData);
80
81 OptionData optionData;
82 optionData.fromXML(XMLUtils::getChildNode(swapNode, "OptionData"));
83 if (parsePositionType(optionData.longShort()) == QuantLib::Position::Long) {
84 vector<LegData> reversedLegData(legData);
85 for (auto& l : reversedLegData)
86 l.isPayer() = !l.isPayer();
87 swaption_ = ore::data::Swaption(envelope(), optionData, reversedLegData);
88 } else {
89 swaption_ = ore::data::Swaption(envelope(), optionData, legData);
90 }
91}
Serializable Swap, Single and Cross Currency.
Definition: swap.hpp:36
Serializable Swaption.
Definition: swaption.hpp:39
virtual void fromXML(XMLNode *node) override
Definition: trade.cpp:34
const Envelope & envelope() const
Definition: trade.hpp:135
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
Definition: xmlutils.cpp:428
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 ( ore::data::XMLDocument doc) const
overridevirtual

Reimplemented from Trade.

Definition at line 93 of file callableswap.cpp.

93 {
94 XMLNode* node = Trade::toXML(doc);
95 XMLNode* swapNode = doc.allocNode("CallableSwapData");
96 XMLUtils::appendNode(node, swapNode);
97
98 for (Size i = 0; i < swap_.legData().size(); i++) {
99 // poor const correctness in ORE, so we copy...
100 LegData ld = swap_.legData()[i];
101 XMLUtils::appendNode(swapNode, ld.toXML(doc));
102 }
103
104 // same as above...
105 OptionData od = swaption_.optionData();
106 XMLUtils::appendNode(swapNode, od.toXML(doc));
107
108 return node;
109}
const vector< LegData > & legData() const
Definition: swap.hpp:74
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: trade.cpp:46
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
Size size(const ValueType &v)
Definition: value.cpp:145
+ Here is the call graph for this function:

◆ additionalData()

const std::map< std::string, boost::any > & additionalData ( ) const
overridevirtual

returns all additional data returned by the trade once built

Reimplemented from Trade.

Definition at line 66 of file callableswap.cpp.

66{ return swap_.additionalData(); }
const std::map< std::string, boost::any > & additionalData() const override
returns all additional data returned by the trade once built
Definition: swap.cpp:228
+ Here is the call graph for this function:

Member Data Documentation

◆ swap_

ore::data::Swap swap_
private

Definition at line 62 of file callableswap.hpp.

◆ swaption_

ore::data::Swaption swaption_
private

Definition at line 63 of file callableswap.hpp.