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

#include <ored/portfolio/barrieroption.hpp>

+ Inheritance diagram for FxOptionWithBarrier:
+ Collaboration diagram for FxOptionWithBarrier:

Public Member Functions

 FxOptionWithBarrier (const std::string &tradeType)
 Default constructor. More...
 
 FxOptionWithBarrier (const std::string &tradeType, ore::data::Envelope &env, ore::data::OptionData option, BarrierData barrier, QuantLib::Date startDate, std::string calendar, std::string boughtCurrency, QuantLib::Real boughtAmount, std::string soldCurrency, QuantLib::Real soldAmount, std::string fxIndex=std::string())
 Constructor. More...
 
Inspectors
QuantLib::Real boughtAmount () const
 
QuantLib::Real soldAmount () const
 
void build (const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &ef) override
 
- Public Member Functions inherited from FxSingleAssetDerivative
const std::string & boughtCurrency () const
 
const std::string & soldCurrency () const
 
const std::string & foreignCurrency () const
 
const std::string & domesticCurrency () 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...
 
- Public Member Functions inherited from BarrierOption
 BarrierOption ()
 Constructor. More...
 
 BarrierOption (ore::data::OptionData option, BarrierData barrier, QuantLib::Date startDate=QuantLib::Date(), const std::string &calendar=std::string())
 
void build (const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &) override
 Build QuantLib/QuantExt instrument, link pricing engine. More...
 
virtual void checkBarriers ()=0
 check validity of barriers More...
 
virtual QuantLib::ext::shared_ptr< QuantLib::Index > getIndex ()=0
 
virtual const QuantLib::Real strike ()=0
 
virtual QuantLib::Real tradeMultiplier ()=0
 
virtual Currency tradeCurrency ()=0
 
virtual QuantLib::ext::shared_ptr< QuantLib::PricingEngine > vanillaPricingEngine (const QuantLib::ext::shared_ptr< EngineFactory > &ef, const QuantLib::Date &expiryDate, const QuantLib::Date &paymentDate)=0
 
virtual QuantLib::ext::shared_ptr< QuantLib::PricingEngine > barrierPricingEngine (const QuantLib::ext::shared_ptr< EngineFactory > &ef, const QuantLib::Date &expiryDate, const QuantLib::Date &paymentDate)=0
 
virtual const QuantLib::Handle< QuantLib::Quote > & spotQuote ()=0
 
virtual void additionalFromXml (ore::data::XMLNode *node)=0
 
virtual void additionalToXml (ore::data::XMLDocument &doc, ore::data::XMLNode *node) const =0
 
virtual std::string indexFixingName ()=0
 
const ore::data::OptionDataoption () const
 
const BarrierDatabarrier () const
 
const QuantLib::Date & startDate () const
 
const QuantLib::Calendar & calendar () const
 

Serialisation

std::string fxIndexStr_
 
QuantLib::ext::shared_ptr< QuantExt::FxIndexfxIndex_
 
QuantLib::Handle< QuantLib::Quote > spotQuote_
 
QuantLib::Real boughtAmount_
 
QuantLib::Real soldAmount_
 
void additionalFromXml (ore::data::XMLNode *node) override
 
void additionalToXml (ore::data::XMLDocument &doc, ore::data::XMLNode *node) const override
 
QuantLib::ext::shared_ptr< QuantLib::Index > getIndex () override
 
const QuantLib::Real strike () override
 
QuantLib::Real tradeMultiplier () override
 
Currency tradeCurrency () override
 
const QuantLib::Handle< QuantLib::Quote > & spotQuote () override
 
std::string indexFixingName () override
 
void fromXML (ore::data::XMLNode *node) override
 
ore::data::XMLNodetoXML (ore::data::XMLDocument &doc) const override
 

Additional Inherited Members

- Protected Member Functions inherited from FxSingleAssetDerivative
 FxSingleAssetDerivative (const std::string &tradeType)
 
 FxSingleAssetDerivative (const std::string &tradeType, ore::data::Envelope &env, const std::string &boughtCurrency, const std::string &soldCurrency)
 
- Protected Member Functions inherited from FxDerivative
 FxDerivative (const std::string &tradeType)
 
 FxDerivative (const std::string &tradeType, ore::data::Envelope &env)
 
- 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 FxSingleAssetDerivative
std::string boughtCurrency_
 
std::string soldCurrency_
 
std::string & foreignCurrency_ = boughtCurrency_
 
std::string & domesticCurrency_ = soldCurrency_
 
- 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_
 
- Protected Attributes inherited from BarrierOption
std::string calendarStr_
 

Detailed Description

Definition at line 101 of file barrieroption.hpp.

Constructor & Destructor Documentation

◆ FxOptionWithBarrier() [1/2]

FxOptionWithBarrier ( const std::string &  tradeType)

Default constructor.

Definition at line 104 of file barrieroption.hpp.

105 boughtAmount_(0.0), soldAmount_(0.0) {}
FxSingleAssetDerivative(const std::string &tradeType)
Trade base class.
Definition: trade.hpp:55
const string & tradeType() const
Definition: trade.hpp:133

◆ FxOptionWithBarrier() [2/2]

FxOptionWithBarrier ( const std::string &  tradeType,
ore::data::Envelope env,
ore::data::OptionData  option,
BarrierData  barrier,
QuantLib::Date  startDate,
std::string  calendar,
std::string  boughtCurrency,
QuantLib::Real  boughtAmount,
std::string  soldCurrency,
QuantLib::Real  soldAmount,
std::string  fxIndex = std::string() 
)

Constructor.

Definition at line 108 of file barrieroption.hpp.

const BarrierData & barrier() const
const QuantLib::Date & startDate() const
const ore::data::OptionData & option() const
const QuantLib::Calendar & calendar() const
QuantLib::Real boughtAmount() const
QuantLib::Real soldAmount() const
const std::string & soldCurrency() const
const std::string & boughtCurrency() const

Member Function Documentation

◆ boughtAmount()

QuantLib::Real boughtAmount ( ) const

Definition at line 119 of file barrieroption.hpp.

119{ return boughtAmount_; }

◆ soldAmount()

QuantLib::Real soldAmount ( ) const

Definition at line 120 of file barrieroption.hpp.

120{ return soldAmount_; }

◆ build()

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

Definition at line 212 of file barrieroption.cpp.

212 {
213
214 // ISDA taxonomy
215 additionalData_["isdaAssetClass"] = string("Foreign Exchange");
216 additionalData_["isdaBaseProduct"] = string("Simple Exotic");
217 additionalData_["isdaSubProduct"] = string("Barrier");
218 additionalData_["isdaTransaction"] = string("");
219
220 additionalData_["boughAmount"] = boughtAmount_;
221 additionalData_["boughtCurrency"] = boughtCurrency_;
222 additionalData_["soldAmount"] = soldAmount_;
223 additionalData_["soldCurrency"] = soldCurrency_;
224
225 npvCurrency_ = soldCurrency_; // sold is the domestic
227 notionalCurrency_ = soldCurrency_; // sold is the domestic
228
229 QuantLib::Date expiryDate = parseDate(option().exerciseDates().front());
230 maturity_ = std::max(option().premiumData().latestPremiumDate(), expiryDate);
231
232 spotQuote_ = ef->market()->fxSpot(boughtCurrency_ + soldCurrency_);
233 fxIndex_ = ef->market()->fxIndex(indexFixingName(), ef->configuration(MarketContext::pricing)).currentLink();
234
236}
void build(const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &) override
Build QuantLib/QuantExt instrument, link pricing engine.
QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex_
QuantLib::Handle< QuantLib::Quote > spotQuote_
std::string indexFixingName() override
string npvCurrency_
Definition: trade.hpp:201
QuantLib::Real notional_
Definition: trade.hpp:202
string notionalCurrency_
Definition: trade.hpp:203
std::map< std::string, boost::any > additionalData_
Definition: trade.hpp:224
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ additionalFromXml()

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

Implements BarrierOption.

Definition at line 238 of file barrieroption.cpp.

238 {
239 fxIndexStr_ = XMLUtils::getChildValue(node, "FXIndex", false);
240 boughtCurrency_ = XMLUtils::getChildValue(node, "BoughtCurrency", true);
241 soldCurrency_ = XMLUtils::getChildValue(node, "SoldCurrency", true);
242 boughtAmount_ = XMLUtils::getChildValueAsDouble(node, "BoughtAmount", true);
243 soldAmount_ = XMLUtils::getChildValueAsDouble(node, "SoldAmount", true);
244}
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
Definition: xmlutils.cpp:286
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
+ Here is the call graph for this function:

◆ additionalToXml()

void additionalToXml ( ore::data::XMLDocument doc,
ore::data::XMLNode node 
) const
overridevirtual

Implements BarrierOption.

Definition at line 246 of file barrieroption.cpp.

246 {
247 if (!fxIndexStr_.empty())
248 XMLUtils::addChild(doc, node, "FXIndex", fxIndexStr_);
249 XMLUtils::addChild(doc, node, "BoughtCurrency", boughtCurrency_);
250 XMLUtils::addChild(doc, node, "BoughtAmount", boughtAmount_);
251 XMLUtils::addChild(doc, node, "SoldCurrency", soldCurrency_);
252 XMLUtils::addChild(doc, node, "SoldAmount", soldAmount_);
253}
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
+ Here is the call graph for this function:

◆ getIndex()

QuantLib::ext::shared_ptr< QuantLib::Index > getIndex ( )
overridevirtual

Implements BarrierOption.

Definition at line 130 of file barrieroption.hpp.

130{ return QuantLib::ext::dynamic_pointer_cast<Index>(fxIndex_); }

◆ strike()

const QuantLib::Real strike ( )
overridevirtual

Implements BarrierOption.

Definition at line 131 of file barrieroption.hpp.

131{ return soldAmount_ / boughtAmount_; }

◆ tradeMultiplier()

QuantLib::Real tradeMultiplier ( )
overridevirtual

Implements BarrierOption.

Definition at line 132 of file barrieroption.hpp.

132{ return boughtAmount_; }

◆ tradeCurrency()

Currency tradeCurrency ( )
overridevirtual

Implements BarrierOption.

Definition at line 133 of file barrieroption.hpp.

133{ return parseCurrency(soldCurrency_); }
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:290
+ Here is the call graph for this function:

◆ spotQuote()

const QuantLib::Handle< QuantLib::Quote > & spotQuote ( )
overridevirtual

Implements BarrierOption.

Definition at line 134 of file barrieroption.hpp.

134{ return spotQuote_; }

◆ indexFixingName()

std::string indexFixingName ( )
overridevirtual

Implements BarrierOption.

Definition at line 205 of file barrieroption.cpp.

205 {
206 if (fxIndexStr_.empty())
208 else
209 return fxIndexStr_;
210}
+ Here is the caller graph for this function:

◆ fromXML()

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

Reimplemented from BarrierOption.

Definition at line 137 of file barrieroption.hpp.

137{ BarrierOption::fromXML(node); }
void fromXML(ore::data::XMLNode *node) override
+ Here is the call graph for this function:

◆ toXML()

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

Reimplemented from BarrierOption.

Definition at line 138 of file barrieroption.hpp.

138{ return BarrierOption::toXML(doc); }
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
+ Here is the call graph for this function:

Member Data Documentation

◆ fxIndexStr_

std::string fxIndexStr_
private

Definition at line 141 of file barrieroption.hpp.

◆ fxIndex_

QuantLib::ext::shared_ptr<QuantExt::FxIndex> fxIndex_
private

Definition at line 142 of file barrieroption.hpp.

◆ spotQuote_

QuantLib::Handle<QuantLib::Quote> spotQuote_
private

Definition at line 143 of file barrieroption.hpp.

◆ boughtAmount_

QuantLib::Real boughtAmount_
private

Definition at line 144 of file barrieroption.hpp.

◆ soldAmount_

QuantLib::Real soldAmount_
private

Definition at line 145 of file barrieroption.hpp.