19#include <boost/make_shared.hpp>
31#include <ql/errors.hpp>
32#include <ql/exercise.hpp>
33#include <ql/instruments/compositeinstrument.hpp>
34#include <ql/instruments/vanillaoption.hpp>
41void FxOption::build(
const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory) {
54 QuantLib::Date today = Settings::instance().evaluationDate();
55 const QuantLib::ext::shared_ptr<Market>& market = engineFactory->market();
61 "FX option trade " <<
id() <<
" has automatic exercise so the FXIndex node needs to be populated.");
78 if (opd->rulesBased()) {
79 const Calendar& cal = opd->calendar();
80 QL_REQUIRE(cal != Calendar(),
"Need a non-empty calendar for rules based payment date.");
83 if (opd->dates().size() > 1)
85 id(),
tradeType(),
"Trade build",
"Found more than 1 payment date. The first one will be used.")
97 ext::shared_ptr<QuantLib::Instrument>
instrument =
111 "Trade build error, exercise after option expiry is not allowed");
131 QL_REQUIRE(fxNode,
"No FxOptionData Node");
140 QL_REQUIRE(
boughtAmount > 0.0,
"positive BoughtAmount required");
141 QL_REQUIRE(
soldAmount > 0.0,
"positive SoldAmount required");
Engine builder for FX Forwards.
Engine builder for FX Options.
double soldAmount() const
const string & soldCurrency() const
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
std::string fxIndex_
If the option has automatic exercise, need an FX index for settlement.
const string & boughtCurrency() const
double boughtAmount() const
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Build QuantLib/QuantExt instrument, link pricing engine.
void log() const
generate Boost log record to pass to corresponding sinks
const string & settlement() const
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
bool isAutomaticExercise() const
Automatic exercise assumed false if not explicitly provided.
const boost::optional< OptionPaymentData > & paymentData() const
const boost::optional< OptionExerciseData > & exerciseData() const
const vector< string > & exerciseDates() const
Utility classes for Structured warnings, contains the Trade ID and Type.
std::vector< bool > legPayers_
std::vector< string > legCurrencies_
std::vector< QuantLib::Leg > legs_
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
const QuantLib::ext::shared_ptr< InstrumentWrapper > & instrument() const
QuantLib::ext::shared_ptr< InstrumentWrapper > instrument_
const string & tradeType() const
std::map< std::string, boost::any > additionalData_
QuantLib::Real value() const
Vanilla Instrument Wrapper.
QuantLib::Date expiryDate_
Store the option expiry date.
QuantLib::Date paymentDate_
Store the (optional) payment date.
const QuantLib::Date paymentDate() const
QuantLib::Date forwardDate_
Store the (optional) forward date.
std::string indexName_
Hold the external index name if needed e.g. in the case of an FX index.
QuantLib::ext::shared_ptr< QuantLib::Index > index_
An index is needed if the option is to be automatically exercised on expiry.
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Build QuantLib/QuantExt instrument, link pricing engine.
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 Forward data model and serialization.
FX 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.
leg data model and serialization
Classes and functions for log message handling.
market data related utilties
QuantLib::Date fixingDate(const QuantLib::Date &d, const QuantLib::Period obsLag, const QuantLib::Frequency freq, bool interpolated)
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)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
Classes for structured trade warnings.