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

Serializable FX One-Touch/No-Touch Option. More...

#include <ored/portfolio/fxtouchoption.hpp>

+ Inheritance diagram for FxTouchOption:
+ Collaboration diagram for FxTouchOption:

Public Member Functions

 FxTouchOption ()
 Default constructor. More...
 
 FxTouchOption (Envelope &env, OptionData option, BarrierData barrier, string foreignCurrency, string domesticCurrency, string payoffCurrency, double payoffAmount, string startDate="", string calendar="", string fxIndex="")
 Constructor. More...
 
void build (const QuantLib::ext::shared_ptr< EngineFactory > &) override
 Build QuantLib/QuantExt instrument, link pricing engine. More...
 
Inspectors
const OptionDataoption () const
 
const BarrierDatabarrier () const
 
double payoffAmount () const
 
const string & type () const
 
const string & payoffCurrency () const
 
const string & startDate () const
 
const string & calendar () const
 
const string & fxIndex () const
 
- 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...
 

Serialisation

OptionData option_
 
BarrierData barrier_
 
string startDate_
 
string calendar_
 
string fxIndex_
 
Real payoffAmount_
 
string type_
 
string payoffCurrency_
 
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (XMLDocument &doc) const override
 
bool checkBarrier (Real spot, Barrier::Type type, Real level)
 

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_
 

Detailed Description

Serializable FX One-Touch/No-Touch Option.

Definition at line 39 of file fxtouchoption.hpp.

Constructor & Destructor Documentation

◆ FxTouchOption() [1/2]

Default constructor.

Definition at line 42 of file fxtouchoption.hpp.

42: ore::data::Trade("FxTouchOption"), FxSingleAssetDerivative("") {}
FxSingleAssetDerivative(const std::string &tradeType)
Trade base class.
Definition: trade.hpp:55

◆ FxTouchOption() [2/2]

FxTouchOption ( Envelope env,
OptionData  option,
BarrierData  barrier,
string  foreignCurrency,
string  domesticCurrency,
string  payoffCurrency,
double  payoffAmount,
string  startDate = "",
string  calendar = "",
string  fxIndex = "" 
)

Constructor.

Definition at line 43 of file fxtouchoption.cpp.

46 : ore::data::Trade("FxTouchOption", env),
50 Barrier::Type barrierType = parseBarrierType(barrier_.type());
51 switch (barrierType) {
52 case Barrier::DownIn:
53 case Barrier::UpIn:
54 type_ = "One-Touch";
55 break;
56 case Barrier::DownOut:
57 case Barrier::UpOut:
58 type_ = "No-Touch";
59 break;
60 default:
61 QL_FAIL("unknown barrier type");
62 }
63}
const std::string & type() const
Definition: barrierdata.hpp:46
const std::string & domesticCurrency() const
const std::string & foreignCurrency() const
const BarrierData & barrier() const
const OptionData & option() const
const string & startDate() const
double payoffAmount() const
const string & fxIndex() const
const string & payoffCurrency() const
const string & calendar() const
Barrier::Type parseBarrierType(const std::string &s)
Convert std::string to QuantLib::BarrierType.
Definition: parsers.cpp:1042
+ Here is the call graph for this function:

Member Function Documentation

◆ build()

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

Build QuantLib/QuantExt instrument, link pricing engine.

Implements Trade.

Definition at line 65 of file fxtouchoption.cpp.

65 {
66
67 // ISDA taxonomy
68 additionalData_["isdaAssetClass"] = string("Foreign Exchange");
69 additionalData_["isdaBaseProduct"] = string("Simple Exotic");
70 additionalData_["isdaSubProduct"] = string("Barrier");
71 additionalData_["isdaTransaction"] = string("");
72
73 additionalData_["payoffAmount"] = payoffAmount_;
74 additionalData_["payoffCurrency"] = payoffCurrency_;
75
79
80 const QuantLib::ext::shared_ptr<Market> market = engineFactory->market();
81
82 QL_REQUIRE(tradeActions().empty(), "TradeActions not supported for FxOption");
83 QL_REQUIRE(option_.exerciseDates().size() == 1, "Invalid number of exercise dates");
84 QL_REQUIRE(barrier_.levels().size() == 1, "Double barriers not supported for FxTouchOptions");
85 QL_REQUIRE(barrier_.style().empty() || barrier_.style() == "American", "Only american barrier style suppported");
86
87 // Parse trade data
88 Currency fgnCcy = parseCurrency(foreignCurrency_);
89 Currency domCcy = parseCurrency(domesticCurrency_);
90 Real level = barrier_.levels()[0].value();
91 Date expiryDate = parseDate(option_.exerciseDates().front());
92
93 Natural payLag = 0;
94 BusinessDayConvention payConvention = Unadjusted;
95 Calendar payCalendar = NullCalendar();
96 Date payDate = expiryDate;
97 const boost::optional<OptionPaymentData>& opd = option_.paymentData();
98 if (opd) {
99 if (opd->rulesBased()) {
100 payLag = opd->lag();
101 payConvention = opd->convention();
102 payCalendar = opd->calendar();
103 payDate = payCalendar.advance(expiryDate, opd->lag(), Days, opd->convention());
104 } else {
105 if (opd->dates().size() > 1)
107 "Found more than 1 payment date. The first one will be used.")
108 .log();
109 payDate = opd->dates().front();
110 }
111 }
112 QL_REQUIRE(payDate >= expiryDate, "Settlement date cannot be earlier than expiry date");
113
114 Barrier::Type barrierType = parseBarrierType(barrier_.type());
115 Option::Type type;
116 if (barrierType == Barrier::DownIn || barrierType == Barrier::DownOut)
117 type = Option::Type::Put;
118 else
119 type = Option::Type::Call;
121 bool payoffAtExpiry = option_.payoffAtExpiry();
122 Real rebate = barrier_.rebate();
123 Position::Type positionType = parsePositionType(option_.longShort());
124 Date start = ore::data::parseDate(startDate_);
125
126 QL_REQUIRE(rebate == 0, "Rebates not supported for FxTouchOptions");
127 QL_REQUIRE(payoffAtExpiry == true || barrierType == Barrier::Type::DownIn || barrierType == Barrier::Type::UpIn,
128 "Payoff at hit not supported for FxNoTouchOptions");
129 if ((barrierType == Barrier::Type::DownIn || barrierType == Barrier::Type::UpIn) && payoffAtExpiry == false)
130 QL_REQUIRE(
131 !opd || (opd->rulesBased() && opd->relativeTo() == OptionPaymentData::RelativeTo::Exercise),
132 "Option payment data must be rules-based and relative to Exercise for FxOneTouchOption with payoff at hit");
133
134 // Handle PayoffCurrency, we might have to flip the trade here
135 bool flipResults = false;
137 // Invert the trade, switch dom and for and flip Put/Call
138 level = 1.0 / level;
139 std::swap(fgnCcy, domCcy);
140 type = type == Option::Call ? Option::Put : Option::Call;
141 switch (barrierType) {
142 case Barrier::DownIn:
143 barrierType = Barrier::UpIn;
144 break;
145 case Barrier::UpIn:
146 barrierType = Barrier::DownIn;
147 break;
148 case Barrier::DownOut:
149 barrierType = Barrier::UpOut;
150 break;
151 case Barrier::UpOut:
152 barrierType = Barrier::DownOut;
153 break;
154 }
155 flipResults = true;
156 } else if (payoffCurrency_ != domesticCurrency_) {
157 QL_FAIL("Invalid Payoff currency (" << payoffCurrency_ << ") for FxTouchOption " << foreignCurrency_
159 }
160 DLOG("Setting up FxTouchOption with level " << level << " foreign/bought " << fgnCcy << " domestic/sold "
161 << domCcy);
162 // from this point on it's important not to use domesticCurrency_, foreignCurrency_, barrier_.level(), etc
163 // rather the local variables (fgnCcy, domCcy, level, etc) should be used as they may have been flipped.
164
165 QuantLib::ext::shared_ptr<QuantExt::FxIndex> fxIndex;
166 if (!fxIndex_.empty())
167 fxIndex = buildFxIndex(fxIndex_, domCcy.code(), fgnCcy.code(), engineFactory->market(),
168 engineFactory->configuration(MarketContext::pricing));
169 Calendar cal = ore::data::parseCalendar(calendar_);
170
171 auto buildBarrierOptionWrapperInstr = [this, type, level, engineFactory, domCcy, fgnCcy, flipResults, positionType,
172 market, barrierType, rebate, fxIndex, cal,
173 start](const Date& expiryDate, const Date& payDate) {
174 QuantLib::ext::shared_ptr<StrikedTypePayoff> payoff(new CashOrNothingPayoff(type, level, 1.0));
175 Leg leg;
176
177 leg.push_back(QuantLib::ext::shared_ptr<CashFlow>(new SimpleCashFlow(1.0, payDate)));
178 // Hard code payoff at expiry to true - we ignore in pricing; QPR-10669
179 bool payoffFlag = true;
180
181 QuantLib::ext::shared_ptr<Exercise> exercise = QuantLib::ext::make_shared<AmericanExercise>(expiryDate, payoffFlag);
182
183 QuantLib::ext::shared_ptr<Instrument> barrier = QuantLib::ext::make_shared<VanillaOption>(payoff, exercise);
184 QuantLib::ext::shared_ptr<Instrument> underlying = QuantLib::ext::make_shared<Swap>(Leg(), leg);
185
186 // set pricing engines
187 QuantLib::ext::shared_ptr<EngineBuilder> builder = engineFactory->builder(tradeType_);
188 QL_REQUIRE(builder, "No builder found for " << tradeType_);
189 QuantLib::ext::shared_ptr<FxTouchOptionEngineBuilder> fxTouchOptBuilder =
190 QuantLib::ext::dynamic_pointer_cast<FxTouchOptionEngineBuilder>(builder);
191 barrier->setPricingEngine(fxTouchOptBuilder->engine(fgnCcy, domCcy, type_, payDate, flipResults));
192 setSensitivityTemplate(*fxTouchOptBuilder);
193 if (type_ == "One-Touch") {
194 // if a one-touch option is triggered it becomes a simple forward cashflow
195 // which we price as a swap
196 builder = engineFactory->builder("Swap");
197 QL_REQUIRE(builder, "No builder found for Swap");
198 QuantLib::ext::shared_ptr<SwapEngineBuilderBase> swapBuilder =
199 QuantLib::ext::dynamic_pointer_cast<SwapEngineBuilderBase>(builder);
200 underlying->setPricingEngine(swapBuilder->engine(domCcy, std::string(), std::string()));
201 }
202
203 bool isLong = (positionType == Position::Long) ? true : false;
204
205 std::vector<QuantLib::ext::shared_ptr<Instrument>> additionalInstruments;
206 std::vector<Real> additionalMultipliers;
207 Date lastPremiumDate =
208 addPremiums(additionalInstruments, additionalMultipliers, (isLong ? 1.0 : -1.0) * payoffAmount_,
209 option_.premiumData(), isLong ? -1.0 : 1.0, parseCurrency(payoffCurrency_), engineFactory,
210 builder->configuration(MarketContext::pricing));
211
212 Handle<Quote> spot = market->fxRate(fgnCcy.code() + domCcy.code());
213
214 auto barrierOptionWrapper = QuantLib::ext::make_shared<SingleBarrierOptionWrapper>(
215 barrier, isLong, expiryDate, false, underlying, barrierType, spot, level, rebate, domCcy, start, fxIndex,
216 cal, payoffAmount_, payoffAmount_, additionalInstruments, additionalMultipliers);
217
218 maturity_ = std::max(lastPremiumDate, payDate);
219
220 return barrierOptionWrapper;
221 };
222
223 auto barrierOptionWrapper = buildBarrierOptionWrapperInstr(expiryDate, payDate);
224
225 // We make sure to add required fixings before checking for modifying the instrument's expiry date, to make sure the
226 // portfolio-analyzer gets all the fixings needed for the instrument at the first evaluation.
227 Calendar fixingCal = fxIndex ? fxIndex->fixingCalendar() : cal;
228 if (start != Date()) {
229 for (Date d = start; d <= expiryDate; d = fixingCal.advance(d, 1 * Days))
231 }
232
233 // Check if the barrier has been triggered already. If payoff-at-hit, and barrier was touched in the past, then
234 // create instrument again, with expiry date and pay date corresponding to that past barrier exercise date
235 if (auto rt = engineFactory->engineData()->globalParameters().find("RunType");
236 rt != engineFactory->engineData()->globalParameters().end() && rt->second != "PortfolioAnalyser" &&
237 barrierOptionWrapper->exercise()) {
238 QL_REQUIRE(barrierOptionWrapper->exerciseDate() != Date(), "Option is exercised but exercise date was not defined");
239 expiryDate = barrierOptionWrapper->exerciseDate();
240 additionalData_["exerciseDate"] = expiryDate;
241
242 if (!payoffAtExpiry && type_ == "One-Touch") {
243 payDate = payCalendar.advance(expiryDate, payLag, Days, payConvention);
244 barrierOptionWrapper = buildBarrierOptionWrapperInstr(expiryDate, payDate);
245 additionalData_["settlementDate"] = payDate;
246 }
247 }
248
249 instrument_ = barrierOptionWrapper;
250
251 // maturity_ is set in buildBarrierOptionWrapperInstr()
252}
double rebate() const
Definition: barrierdata.hpp:47
std::vector< ore::data::TradeBarrier > levels() const
Definition: barrierdata.hpp:50
const std::string & style() const
Definition: barrierdata.hpp:51
const string & type() const
void log() const
generate Boost log record to pass to corresponding sinks
Definition: log.cpp:491
void setCallPut(const string &callPut)
Definition: optiondata.hpp:102
const string & longShort() const
Definition: optiondata.hpp:70
const bool & payoffAtExpiry() const
Definition: optiondata.hpp:75
const boost::optional< OptionPaymentData > & paymentData() const
Definition: optiondata.hpp:93
const PremiumData & premiumData() const
Definition: optiondata.hpp:83
const vector< string > & exerciseDates() const
Definition: optiondata.hpp:76
void addFixingDate(const QuantLib::Date &fixingDate, const std::string &indexName, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
Utility classes for Structured warnings, contains the Trade ID and Type.
TradeActions & tradeActions()
Set the trade actions.
Definition: trade.hpp:126
string npvCurrency_
Definition: trade.hpp:201
QuantLib::Real notional_
Definition: trade.hpp:202
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)
Definition: trade.cpp:58
void setSensitivityTemplate(const EngineBuilder &builder)
Definition: trade.cpp:295
string tradeType_
Definition: trade.hpp:196
RequiredFixings requiredFixings_
Definition: trade.hpp:223
QuantLib::ext::shared_ptr< InstrumentWrapper > instrument_
Definition: trade.hpp:197
string notionalCurrency_
Definition: trade.hpp:203
const string & tradeType() const
Definition: trade.hpp:133
std::map< std::string, boost::any > additionalData_
Definition: trade.hpp:224
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
Definition: parsers.cpp:157
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:290
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
Definition: parsers.cpp:404
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
QuantLib::ext::shared_ptr< QuantExt::FxIndex > buildFxIndex(const string &fxIndex, const string &domestic, const string &foreign, const QuantLib::ext::shared_ptr< Market > &market, const string &configuration, bool useXbsCurves)
Definition: marketdata.cpp:137
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ option()

const OptionData & option ( ) const

Definition at line 53 of file fxtouchoption.hpp.

53{ return option_; }

◆ barrier()

const BarrierData & barrier ( ) const

Definition at line 54 of file fxtouchoption.hpp.

54{ return barrier_; }
+ Here is the caller graph for this function:

◆ payoffAmount()

double payoffAmount ( ) const

Definition at line 55 of file fxtouchoption.hpp.

55{ return payoffAmount_; }

◆ type()

const string & type ( ) const

Definition at line 56 of file fxtouchoption.hpp.

56{ return type_; }
+ Here is the caller graph for this function:

◆ payoffCurrency()

const string & payoffCurrency ( ) const

Definition at line 57 of file fxtouchoption.hpp.

57{ return payoffCurrency_; }

◆ startDate()

const string & startDate ( ) const

Definition at line 58 of file fxtouchoption.hpp.

58{ return startDate_; }

◆ calendar()

const string & calendar ( ) const

Definition at line 59 of file fxtouchoption.hpp.

59{ return calendar_; }

◆ fxIndex()

const string & fxIndex ( ) const

Definition at line 60 of file fxtouchoption.hpp.

60{ return fxIndex_; }
+ Here is the caller graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Reimplemented from Trade.

Definition at line 267 of file fxtouchoption.cpp.

267 {
268 Trade::fromXML(node);
269 XMLNode* fxNode = XMLUtils::getChildNode(node, "FxTouchOptionData");
270 QL_REQUIRE(fxNode, "No FxOptionData Node");
271 option_.fromXML(XMLUtils::getChildNode(fxNode, "OptionData"));
272 barrier_.fromXML(XMLUtils::getChildNode(fxNode, "BarrierData"));
273 Barrier::Type barrierType = parseBarrierType(barrier_.type());
274 switch (barrierType) {
275 case Barrier::DownIn:
276 case Barrier::UpIn:
277 type_ = "One-Touch";
278 break;
279 case Barrier::DownOut:
280 case Barrier::UpOut:
281 type_ = "No-Touch";
282 break;
283 default:
284 QL_FAIL("unknown barrier type");
285 }
286
287 foreignCurrency_ = XMLUtils::getChildValue(fxNode, "ForeignCurrency", true);
288 domesticCurrency_ = XMLUtils::getChildValue(fxNode, "DomesticCurrency", true);
289 payoffCurrency_ = XMLUtils::getChildValue(fxNode, "PayoffCurrency", true);
290 startDate_ = XMLUtils::getChildValue(fxNode, "StartDate", false);
291 calendar_ = XMLUtils::getChildValue(fxNode, "Calendar", false);
292 fxIndex_ = XMLUtils::getChildValue(fxNode, "FXIndex", false);
293 payoffAmount_ = XMLUtils::getChildValueAsDouble(fxNode, "PayoffAmount", true);
294}
virtual void fromXML(ore::data::XMLNode *node) override
Definition: barrierdata.cpp:25
virtual void fromXML(XMLNode *node) override
Definition: optiondata.cpp:32
virtual void fromXML(XMLNode *node) override
Definition: trade.cpp:34
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
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 296 of file fxtouchoption.cpp.

296 {
297 XMLNode* node = Trade::toXML(doc);
298 XMLNode* fxNode = doc.allocNode("FxTouchOptionData");
299 XMLUtils::appendNode(node, fxNode);
300 XMLUtils::appendNode(fxNode, option_.toXML(doc));
301 XMLUtils::appendNode(fxNode, barrier_.toXML(doc));
302 XMLUtils::addChild(doc, fxNode, "ForeignCurrency", foreignCurrency_);
303 XMLUtils::addChild(doc, fxNode, "DomesticCurrency", domesticCurrency_);
304 XMLUtils::addChild(doc, fxNode, "PayoffCurrency", payoffCurrency_);
305 XMLUtils::addChild(doc, fxNode, "PayoffAmount", payoffAmount_);
306 if (startDate_ != "")
307 XMLUtils::addChild(doc, fxNode, "StartDate", startDate_);
308 if (fxIndex_ != "")
309 XMLUtils::addChild(doc, fxNode, "FXIndex", fxIndex_);
310 if (calendar_ != "")
311 XMLUtils::addChild(doc, fxNode, "Calendar", calendar_);
312
313 return node;
314}
virtual ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
Definition: barrierdata.cpp:49
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: optiondata.cpp:86
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: trade.cpp:46
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:

◆ checkBarrier()

bool checkBarrier ( Real  spot,
Barrier::Type  type,
Real  level 
)
private

Definition at line 254 of file fxtouchoption.cpp.

254 {
255 switch (type) {
256 case Barrier::DownIn:
257 case Barrier::DownOut:
258 return spot <= barrier;
259 case Barrier::UpIn:
260 case Barrier::UpOut:
261 return spot >= barrier;
262 default:
263 QL_FAIL("unknown barrier type " << type);
264 }
265}
+ Here is the call graph for this function:

Member Data Documentation

◆ option_

OptionData option_
private

Definition at line 71 of file fxtouchoption.hpp.

◆ barrier_

BarrierData barrier_
private

Definition at line 72 of file fxtouchoption.hpp.

◆ startDate_

string startDate_
private

Definition at line 73 of file fxtouchoption.hpp.

◆ calendar_

string calendar_
private

Definition at line 74 of file fxtouchoption.hpp.

◆ fxIndex_

string fxIndex_
private

Definition at line 75 of file fxtouchoption.hpp.

◆ payoffAmount_

Real payoffAmount_
private

Definition at line 76 of file fxtouchoption.hpp.

◆ type_

string type_
private

Definition at line 77 of file fxtouchoption.hpp.

◆ payoffCurrency_

string payoffCurrency_
private

Definition at line 78 of file fxtouchoption.hpp.