21#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/vanillaoption.hpp>
44 const string& currency, Real quantity,
TradeStrike strike,
45 const boost::optional<bool>& isFuturePrice,
const Date& futureExpiryDate)
47 isFuturePrice_(isFuturePrice), futureExpiryDate_(futureExpiryDate) {
56 additionalData_[
"isdaSubProduct"] = std::string(
"Price Return Basic Performance");
76 const QuantLib::ext::shared_ptr<Market>& market = engineFactory->market();
91 QL_REQUIRE(expiryDates.size() == 1,
92 "Expected exactly one expiry date for CommodityOption but got " << expiryDates.size() <<
".");
97 index_ = index->clone(expiryDate);
102 if (et == Exercise::European && QuantLib::ext::dynamic_pointer_cast<CommodityFuturesIndex>(
index_)) {
111 if (
expiryDate_ > Settings::instance().evaluationDate()) {
118std::map<AssetClass, std::set<std::string>>
128 QL_REQUIRE(commodityNode,
"A commodity option needs a 'CommodityOptionData' node");
QuantLib::Date futureExpiryDate_
std::map< AssetClass, std::set< std::string > > underlyingIndices(const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
Add underlying Commodity names.
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
void build(const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory) override
Build underlying instrument and link pricing engine.
CommodityOption()
Default constructor.
boost::optional< bool > isFuturePrice_
Serializable object holding generic trade data, reporting dimensions.
Serializable object holding option data.
const string & style() const
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
const vector< string > & exerciseDates() const
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
std::map< std::string, boost::any > additionalData_
XMLNode * toXML(XMLDocument &doc) const
void fromXML(XMLNode *node, const bool isRequired=true, const bool allowYieldStrike=false)
QuantLib::Real value() const
void setValue(const QuantLib::Real &value)
Serializable Vanilla Option.
void setNotionalAndCurrencies()
QuantLib::Date expiryDate_
Store the option expiry date.
QuantLib::Date forwardDate_
Store the (optional) forward date.
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 string getNodeValue(XMLNode *node)
Get a node's value.
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
Commodity option representation.
Exercise::Type parseExerciseType(const std::string &s)
Convert text to QuantLib::Exercise::Type.
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
bool parseBool(const string &s)
Convert text to bool.
Classes and functions for log message handling.
#define DLOG(text)
Logging Macro (Level = Debug)
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
std::string to_string(const LocationInfo &l)
Serializable Credit Default Swap.
string conversion utilities