17#include <boost/make_shared.hpp>
23#include <ql/errors.hpp>
24#include <ql/exercise.hpp>
25#include <ql/instruments/compositeinstrument.hpp>
26#include <ql/instruments/payoffs.hpp>
27#include <ql/instruments/vanillaoption.hpp>
49 QL_REQUIRE(
tradeActions().empty(),
"TradeActions not supported for FxDigitalOption");
60 bool flipResults =
false;
66 std::swap(domCcy, forCcy);
67 type = type == Option::Call ? Option::Put : Option::Call;
70 QL_FAIL(
"Invalid Payoff currency (" <<
payoffCurrency_ <<
") for FxDigitalOption " << forCcy << domCcy);
72 DLOG(
"Setting up FxDigitalOption with strike " <<
strike <<
" foreign " << forCcy <<
" domestic " << domCcy);
75 QuantLib::ext::shared_ptr<StrikedTypePayoff> payoff(
new CashOrNothingPayoff(type,
strike,
payoffAmount_));
83 QuantLib::ext::shared_ptr<Exercise> exercise = QuantLib::ext::make_shared<EuropeanExercise>(expiryDate);
88 QuantLib::ext::shared_ptr<Instrument> vanilla = QuantLib::ext::make_shared<VanillaOption>(payoff, exercise);
91 QuantLib::ext::shared_ptr<EngineBuilder> builder = engineFactory->builder(
tradeType_);
92 QL_REQUIRE(builder,
"No builder found for " <<
tradeType_);
93 QuantLib::ext::shared_ptr<FxDigitalOptionEngineBuilder> fxOptBuilder =
94 QuantLib::ext::dynamic_pointer_cast<FxDigitalOptionEngineBuilder>(builder);
95 vanilla->setPricingEngine(fxOptBuilder->engine(forCcy, domCcy, flipResults));
99 Real bsInd = (positionType == QuantLib::Position::Long ? 1.0 : -1.0);
102 std::vector<QuantLib::ext::shared_ptr<Instrument>> additionalInstruments;
103 std::vector<Real> additionalMultipliers;
107 instrument_ = QuantLib::ext::shared_ptr<InstrumentWrapper>(
108 new VanillaInstrument(vanilla, mult, additionalInstruments, additionalMultipliers));
114 QL_REQUIRE(fxNode,
"No FxDigitalOptionData Node");
Engine builder for FX Options.
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Build QuantLib/QuantExt instrument, link pricing engine.
std::string & domesticCurrency_
std::string & foreignCurrency_
const string & callPut() const
const string & longShort() const
const string & style() const
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
const bool & payoffAtExpiry() const
const PremiumData & premiumData() const
const vector< string > & exerciseDates() const
QuantLib::Date latestPremiumDate() const
TradeActions & tradeActions()
Set the trade actions.
virtual void fromXML(XMLNode *node) override
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 setSensitivityTemplate(const EngineBuilder &builder)
virtual XMLNode * toXML(XMLDocument &doc) const override
QuantLib::ext::shared_ptr< InstrumentWrapper > instrument_
std::map< std::string, boost::any > additionalData_
Vanilla Instrument Wrapper.
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
FX Digital Option data model and serialization.
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
Option::Type parseOptionType(const std::string &s)
Convert text to QuantLib::Option::Type.
Classes and functions for log message handling.
#define DLOG(text)
Logging Macro (Level = Debug)
Serializable Credit Default Swap.