27#include <qle/instruments/pairwisevarianceswap.hpp>
41 Schedule valuationSchedule;
44 Schedule laggedValuationSchedule;
49 scheduleBuilder.
add(laggedValuationSchedule, laggedValuationScheduleData);
59 QL_REQUIRE(valuationSchedule.dates().size() == laggedValuationSchedule.dates().size(),
61 <<
" ValuationSchedule and LaggedValuationSchedule must have the same number of dates.");
66 "Trade " <<
id() <<
": PairwiseVarSwap::build() basket strike must be positive (" <<
basketStrike_
69 "Trade " <<
id() <<
": PairwiseVarSwap::build() basket notional must be non-negative (" <<
notional_
72 QuantLib::ext::shared_ptr<QuantExt::PairwiseVarianceSwap> pairwiseVarSwap(
new QuantExt::PairwiseVarianceSwap(
75 laggedValuationSchedule, settlementDate));
78 QuantLib::ext::shared_ptr<ore::data::EngineBuilder> builder = engineFactory->builder(
tradeType_);
79 QL_REQUIRE(builder,
"No builder found for " <<
tradeType_);
80 QuantLib::ext::shared_ptr<PairwiseVarSwapEngineBuilder> pairwiseVarSwapBuilder =
81 QuantLib::ext::dynamic_pointer_cast<PairwiseVarSwapEngineBuilder>(builder);
83 pairwiseVarSwap->setPricingEngine(pairwiseVarSwapBuilder->engine(
107 QL_REQUIRE(underlyingsNode,
"Trade " <<
id() <<
": Must provide an Underlyings node");
110 const string underlyingNodeName =
"Value";
113 "Trade " <<
id() <<
": Must provide two \"Value\" sub-nodes in the Underlyings node");
116 string uVal, uName, acString;
117 vector<AssetClass> assetClasses;
121 if (boost::starts_with(uVal,
"COMM-")) {
123 acString =
"Commodity";
124 uName = uVal.substr(5);
125 }
else if (boost::starts_with(uVal,
"EQ-")) {
128 uName = uVal.substr(3);
129 }
else if (boost::starts_with(uVal,
"FX-")) {
132 uName = uVal.substr(3);
134 QL_FAIL(
"Unsupported underlying type for " << uVal);
138 QuantLib::ext::shared_ptr<ore::data::Underlying> underlying(
new ore::data::Underlying(acString, uName, 1.0));
139 assetClasses.push_back(ac);
143 QL_REQUIRE(assetClasses[0] == assetClasses[1],
144 "Trade " <<
id() <<
": Both underlyings must belong to the same asset class.");
161 QL_REQUIRE(valuationSchedule,
"Trade " <<
id() <<
": Must provide a \"ValuationSchedule\" node");
168 "Trade " <<
id() <<
" Shift value for ValutionSchedule must be at least -1D or less");
173 if (laggedValuationSchedule) {
180 <<
" Shift value for LaggedValuationSchedule must be at least 1D or greater");
198 for (
int i = 0; i < 2; i++) {
224std::map<AssetClass, std::set<std::string>>
std::map< AssetClass, std::set< std::string > > underlyingIndices(const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
Add underlying Equity names.
vector< QuantLib::ext::shared_ptr< Underlying > > underlyings_
vector< Real > underlyingStrikes_
ScheduleData valuationSchedule_
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
ScheduleData laggedValuationSchedule_
const vector< QuantLib::ext::shared_ptr< Underlying > > & underlyings() const
vector< Real > underlyingNotionals_
AssetClass assetClassUnderlyings_
vector< string > indexNames_
AssetClass & assetClassUnderlyings()
const string & longShort()
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
void addFixingDates(const std::vector< std::pair< QuantLib::Date, bool > > &fixingDates, const std::string &indexName, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false)
void makeSchedules(const QuantLib::Date &openEndDateReplacement=QuantLib::Null< QuantLib::Date >())
void add(QuantLib::Schedule &schedule, const ScheduleData &scheduleData)
Serializable schedule data.
const vector< ScheduleDerived > & derived() const
bool hasData() const
Check if has any dates/rules/derived schedules.
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
const bool & hasDerived() const
const string & name() const
Serializable object holding Derived schedule data.
virtual void fromXML(XMLNode *node) override
void setSensitivityTemplate(const EngineBuilder &builder)
virtual XMLNode * toXML(XMLDocument &doc) const override
RequiredFixings requiredFixings_
QuantLib::ext::shared_ptr< InstrumentWrapper > instrument_
const string & tradeType() const
Class to hold Underlyings.
Vanilla Instrument Wrapper.
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
static vector< Real > getChildrenValuesAsDoubles(XMLNode *node, const string &names, const string &name, bool mandatory=false)
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
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 int getChildValueAsInt(XMLNode *node, const string &name, bool mandatory=false, int defaultValue=0)
static void setNodeName(XMLDocument &doc, XMLNode *node, const string &name)
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
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.
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
Serializable Credit Default Swap.
pairwise variance swap representation
Map text representations to QuantLib/QuantExt types.
Reference data model and serialization.