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

Serializable Convertible Bond. More...

#include <ored/portfolio/ascot.hpp>

+ Inheritance diagram for Ascot:
+ Collaboration diagram for Ascot:

Public Member Functions

 Ascot ()
 Default constructor. More...
 
 Ascot (const Envelope &env, const ConvertibleBond &bond, const OptionData &optionData, const ore::data::LegData &fundingLegData)
 Constructor for coupon bonds. More...
 
void build (const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &) override
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (XMLDocument &doc) const override
 
std::map< AssetClass, std::set< std::string > > underlyingIndices (const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
 
const ConvertibleBondbond () const
 
const OptionDataoptionData () const
 
const ore::data::LegDatafundingLegData () const
 
const string & creditCurveId () 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...
 
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...
 

Private Attributes

ConvertibleBond bond_
 
OptionData optionData_
 
ore::data::LegData fundingLegData_
 

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 Convertible Bond.

Definition at line 35 of file ascot.hpp.

Constructor & Destructor Documentation

◆ Ascot() [1/2]

Ascot ( )

Default constructor.

Definition at line 38 of file ascot.hpp.

38: Trade("Ascot") {}
Trade()
Default constructor.
Definition: trade.hpp:59

◆ Ascot() [2/2]

Ascot ( const Envelope env,
const ConvertibleBond bond,
const OptionData optionData,
const ore::data::LegData fundingLegData 
)

Constructor for coupon bonds.

Definition at line 41 of file ascot.hpp.

43 : Trade("Ascot", env), bond_(bond), optionData_(optionData), fundingLegData_(fundingLegData) {}
ext::shared_ptr< ConvertibleBond2 > bond_
OptionData optionData_
Definition: ascot.hpp:60
ore::data::LegData fundingLegData_
Definition: ascot.hpp:61

Member Function Documentation

◆ build()

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

Definition at line 38 of file ascot.cpp.

38 {
39 DLOG("Ascot::build() called for trade " << id());
40
41 // ISDA taxonomy
42 additionalData_["isdaAssetClass"] = string("Credit");
43 additionalData_["isdaBaseProduct"] = string("Exotic");
44 additionalData_["isdaSubProduct"] = string("Other");
45 additionalData_["isdaTransaction"] = string("");
46
47 // build underlying convertible bond
48 bond_.reset();
49 // we need to do set the id manually because it otherwise remains blank
50 bond_.id() = id() + "_Bond";
51 bond_.build(engineFactory);
52 requiredFixings_.addData(bond_.requiredFixings());
53 QuantLib::ext::shared_ptr<QuantExt::ConvertibleBond2> cb =
54 QuantLib::ext::dynamic_pointer_cast<QuantExt::ConvertibleBond2>(bond_.instrument()->qlInstrument());
55
56 // check option fields
57 Exercise::Type exerciseType = parseExerciseType(optionData_.style());
58 QL_REQUIRE(exerciseType == Exercise::American, "expected American exercise type");
59 QL_REQUIRE(optionData_.exerciseDates().size() == 1,
60 "Ascot::build(): exactly one option date required, found " << optionData_.exerciseDates().size());
61 Date exerciseDate = parseDate(optionData_.exerciseDates().back());
62 QuantLib::ext::shared_ptr<Exercise> exercise = QuantLib::ext::make_shared<AmericanExercise>(exerciseDate);
63 Option::Type type = parseOptionType(optionData_.callPut());
64
65 // build funding leg
66 // Payer should be false,
67 // i.e. the swap is entered from the viewpoint of the asset swap buyer
68 QL_REQUIRE(fundingLegData_.isPayer() == false, "expected isPayer == false for funding leg");
69 Leg fundingLeg;
70
71 auto builder = QuantLib::ext::dynamic_pointer_cast<AscotEngineBuilder>(engineFactory->builder("Ascot"));
72 auto configuration = builder->configuration(MarketContext::pricing);
73 auto legBuilder = engineFactory->legBuilder(fundingLegData_.legType());
74 fundingLeg = legBuilder->buildLeg(fundingLegData_, engineFactory, requiredFixings_, configuration);
75
76 QL_REQUIRE(builder, "Ascot::build(): could not cast to AscotBuilder, this is unexpected");
77
78 auto qlAscot =
79 QuantLib::ext::make_shared<QuantExt::Ascot>(type, exercise, bond_.data().bondData().bondNotional(), cb, fundingLeg);
80 qlAscot->setPricingEngine(builder->engine(id(), bond_.data().bondData().currency()));
81 setSensitivityTemplate(*builder);
82
83 Real multiplier = (parsePositionType(optionData_.longShort()) == Position::Long ? 1.0 : -1.0);
85 QuantLib::ext::shared_ptr<ore::data::InstrumentWrapper>(new ore::data::VanillaInstrument(qlAscot, multiplier));
86
87 npvCurrency_ = notionalCurrency_ = bond_.notionalCurrency();
88 legs_ = {cb->cashflows()};
90 legPayers_ = {parsePositionType(optionData_.longShort()) == Position::Long};
91
92 notional_ = bond_.data().bondData().bondNotional();
93 maturity_ = bond_.maturity();
94}
const Leg & fundingLeg() const
ext::shared_ptr< Exercise > exercise()
bool isPayer() const
Definition: legdata.hpp:872
const string & legType() const
Definition: legdata.hpp:890
const string & callPut() const
Definition: optiondata.hpp:71
const string & longShort() const
Definition: optiondata.hpp:70
const string & style() const
Definition: optiondata.hpp:74
const vector< string > & exerciseDates() const
Definition: optiondata.hpp:76
void addData(const RequiredFixings &requiredFixings)
string npvCurrency_
Definition: trade.hpp:201
std::vector< bool > legPayers_
Definition: trade.hpp:200
std::vector< string > legCurrencies_
Definition: trade.hpp:199
std::vector< QuantLib::Leg > legs_
Definition: trade.hpp:198
QuantLib::Real notional_
Definition: trade.hpp:202
void setSensitivityTemplate(const EngineBuilder &builder)
Definition: trade.cpp:295
string & id()
Set the trade id.
Definition: trade.hpp:118
RequiredFixings requiredFixings_
Definition: trade.hpp:223
QuantLib::ext::shared_ptr< InstrumentWrapper > instrument_
Definition: trade.hpp:197
string notionalCurrency_
Definition: trade.hpp:203
std::map< std::string, boost::any > additionalData_
Definition: trade.hpp:224
Vanilla Instrument Wrapper.
Exercise::Type parseExerciseType(const std::string &s)
Convert text to QuantLib::Exercise::Type.
Definition: parsers.cpp:466
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
Definition: parsers.cpp:404
Option::Type parseOptionType(const std::string &s)
Convert text to QuantLib::Option::Type.
Definition: parsers.cpp:481
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
+ Here is the call graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Reimplemented from Trade.

Definition at line 96 of file ascot.cpp.

96 {
97 Trade::fromXML(node);
98 XMLNode* dataNode = XMLUtils::getChildNode(node, "AscotData");
99 QL_REQUIRE(dataNode, "AscotData node not found");
100
101 ConvertibleBondData bondData;
102 bondData.fromXML(XMLUtils::getChildNode(dataNode, "ConvertibleBondData"));
103 bond_ = ConvertibleBond(envelope(), bondData);
104
105 optionData_.fromXML(XMLUtils::getChildNode(dataNode, "OptionData"));
106
107 XMLNode* tmpNode = XMLUtils::getChildNode(dataNode, "ReferenceSwapData");
108 QL_REQUIRE(tmpNode, "ReferenceSwapData node not found");
109 XMLNode* legNode = XMLUtils::getChildNode(tmpNode, "LegData");
110 QL_REQUIRE(legNode, "LegData node not found");
111 fundingLegData_.fromXML(legNode);
112}
virtual void fromXML(XMLNode *node) override
Definition: legdata.cpp:759
virtual void fromXML(XMLNode *node) override
Definition: optiondata.cpp:32
const Envelope & envelope() const
Definition: trade.hpp:135
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 114 of file ascot.cpp.

114 {
115 XMLNode* node = Trade::toXML(doc);
116 XMLNode* dataNode = doc.allocNode("AscotData");
117 XMLUtils::appendNode(node, dataNode);
118
119 ConvertibleBondData d = bond_.data();
120 XMLUtils::appendNode(dataNode, d.toXML(doc));
121 XMLUtils::appendNode(dataNode, optionData_.toXML(doc));
122
123 XMLNode* fundingDataNode = doc.allocNode("ReferenceSwapData");
124 XMLUtils::appendNode(dataNode, fundingDataNode);
125 XMLUtils::appendNode(fundingDataNode, fundingLegData_.toXML(doc));
126
127 return node;
128}
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: legdata.cpp:856
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: optiondata.cpp:86
+ Here is the call graph for this function:

◆ underlyingIndices()

std::map< AssetClass, std::set< std::string > > underlyingIndices ( const QuantLib::ext::shared_ptr< ReferenceDataManager > &  referenceDataManager = nullptr) const
overridevirtual

Reimplemented from Trade.

Definition at line 34 of file ascot.cpp.

34 {
35 return bond_.underlyingIndices(referenceDataManager);
36}

◆ bond()

const ConvertibleBond & bond ( ) const

Definition at line 51 of file ascot.hpp.

51{ return bond_; }

◆ optionData()

const OptionData & optionData ( ) const

Definition at line 52 of file ascot.hpp.

52{ return optionData_; }

◆ fundingLegData()

const ore::data::LegData & fundingLegData ( ) const

Definition at line 53 of file ascot.hpp.

53{ return fundingLegData_; }

◆ creditCurveId()

const string & creditCurveId ( ) const

Definition at line 56 of file ascot.hpp.

56{ return bond_.data().bondData().creditCurveId(); }

Member Data Documentation

◆ bond_

ConvertibleBond bond_
private

Definition at line 59 of file ascot.hpp.

◆ optionData_

OptionData optionData_
private

Definition at line 60 of file ascot.hpp.

◆ fundingLegData_

ore::data::LegData fundingLegData_
private

Definition at line 61 of file ascot.hpp.