21#include <boost/lexical_cast.hpp>
27struct StrikeValue :
public boost::static_visitor<QuantLib::Real> {
29 QuantLib::Real operator()(
const TradeMonetary& s)
const {
return s.value(); }
30 QuantLib::Real operator()(
const TradeStrike::StrikeYield& s)
const {
return s.yield; }
55 QL_REQUIRE(allowYieldStrike,
"StrikeYield not supported for this trade type.");
90 auto sp = QuantLib::ext::get<StrikePrice>(
strike_);
91 node = doc.
allocNode(
"Strike", boost::lexical_cast<std::string>(sp.valueString()));
107 sp.toXMLNode(doc, subNode);
116 return boost::apply_visitor(StrikeValue(),
strike_);
120 QL_REQUIRE(
type_ ==
Type::Price,
"TradeStrike currency only valid when Strike type is Price");
125 QL_REQUIRE(
type_ ==
Type::Yield,
"TradeStrike currency only valid when Strike type is Yield");
138 QL_REQUIRE(
type_ ==
Type::Price,
"TradeStrike currency only valid when Strike type is Price");
144 return value() == Null<Real>();
std::string currency() const
void setCurrency(const std::string ¤cy)
void fromXMLNode(XMLNode *node)
void setValue(const QuantLib::Real &value)
void toXMLNode(XMLDocument &doc, XMLNode *node)
const QuantLib::Compounding & compounding()
boost::variant< StrikeYield, StrikePrice > strike_
XMLNode * toXML(XMLDocument &doc) const
void setCurrency(const std::string ¤cy)
void fromXML(XMLNode *node, const bool isRequired=true, const bool allowYieldStrike=false)
StrikeYield & strikeYield() const
QuantLib::Real value() const
void setValue(const QuantLib::Real &value)
StrikePrice & strikePrice() const
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)
SafeStack< ValueType > value
Compounding parseCompounding(const string &s)
Convert text to QuantLib::Compounding;.
std::string to_string(const LocationInfo &l)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
QuantLib::Compounding compounding