31 :
Swap(env, leg0, leg1,
"EquitySwap") {}
37 for (Size i = 0; i <
legData.size(); ++i) {
38 if (
legData[i].legType() ==
"Equity") {
45 "An Equity Swap must have 2 legs, an Equity Leg and an IR Leg - Trade: " +
id());
50 DLOG(
"EquitySwap::build() called for " <<
id());
55 <<
") out of range, legData has size "
56 <<
legData_.size() <<
", this is unexpected");
58 <<
legData_.size() <<
", this is unexpected");
62 auto eqLegData = QuantLib::ext::dynamic_pointer_cast<EquityLegData>(
legData_[
equityLegIndex_].concreteLegData());
63 QL_REQUIRE(eqLegData,
"could not cast to EquityLegData for equity leg in equity swap, this is unexpected");
66 DLOG(
"adding indexing information from equity leg to funding leg");
69 std::vector<string> valuationDates;
74 for (Size i = 0; i < tmpEqLeg.size(); ++i) {
75 auto eqCpn = QuantLib::ext::dynamic_pointer_cast<QuantExt::EquityCoupon>(tmpEqLeg[i]);
76 QL_REQUIRE(eqCpn,
"EquitySwap::build(): expected EquityCoupon on equity leg, this is unexpected");
78 if (i == tmpEqLeg.size() - 1)
84 QL_REQUIRE(eqLegData->quantity() != Null<Real>(),
85 "indexing can only be added to funding leg, if quantity is given on equity leg");
86 Indexing eqIndexing(
"EQ-" + eqLegData->eqName(),
"",
false,
false,
false, eqLegData->quantity(),
87 eqLegData->initialPrice(), Null<Real>(), valuationSchedule, 0,
"",
"U",
false);
91 if (!eqLegData->fxIndex().empty()) {
92 Real initialFxFixing = Null<Real>();
95 if (!eqLegData->initialPriceCurrency().empty() &&
97 eqLegData->initialPrice() != Null<Real>())
98 initialFxFixing = 1.0;
99 Indexing fxIndexing(eqLegData->fxIndex(),
"",
false,
false,
false, 1.0, initialFxFixing, Null<Real>(),
100 valuationSchedule, 0,
"",
"U",
false);
126 additionalData_[
"isdaSubProduct"] = string(
"Price Return Basic Performance");
132 Date asof = Settings::instance().evaluationDate();
134 if (
auto cpn = QuantLib::ext::dynamic_pointer_cast<QuantExt::EquityCoupon>(c)) {
135 if (c->date() > asof)
136 return cpn->nominal();
139 ALOG(
"Error retrieving current notional for equity swap " <<
id() <<
" as of " << io::iso_date(asof));
Serializable object holding generic trade data, reporting dimensions.
std::string notionalCurrency() const override
void setIsdaTaxonomyFields() override
QuantLib::Real notional() const override
Return the current notional in npvCurrency. See individual sub-classes for the precise definition.
void checkEquitySwap(const vector< LegData > &legData)
EquitySwap()
Default constructor.
virtual void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Trade interface.
Serializable object holding indexing data.
Serializable object holding leg data.
Serializable schedule data.
Serializable object holding schedule Dates data.
Serializable Swap, Single and Cross Currency.
const vector< LegData > & legData() const
std::string notionalCurrency() const override
vector< LegData > legData_
virtual void setIsdaTaxonomyFields()
virtual void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Build QuantLib/QuantExt instrument, link pricing engine.
std::vector< string > legCurrencies_
std::vector< QuantLib::Leg > legs_
std::map< std::string, boost::any > additionalData_
Equity Swap data model and serialization.
Logic for calculating required fixing dates on legs.
#define DLOG(text)
Logging Macro (Level = Debug)
#define ALOG(text)
Logging Macro (Level = Alert)
std::string to_string(const LocationInfo &l)
Serializable Credit Default Swap.
string conversion utilities