277 {
278 auto eqData = QuantLib::ext::dynamic_pointer_cast<EquityLegData>(
data.concreteLegData());
279 QL_REQUIRE(eqData, "Wrong LegType, expected Equity");
280 string eqName = eqData->eqName();
281 auto eqCurve = *engineFactory->market()->equityCurve(eqName, configuration);
282
283
284 if (eqData->returnType() == EquityReturnType::Dividend) {
285 Real spotVal = eqCurve->equitySpot()->value();
286 Handle<Quote> divSpot = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(spotVal));
287 eqCurve = eqCurve->clone(divSpot, eqCurve->equityForecastCurve(), eqCurve->equityDividendCurve());
288 }
289
291 Currency eqCurrency;
292
293 if (!eqData->eqCurrency().empty())
295
296 if (eqCurve->currency().empty()) {
297 WLOG(
"No equity currency set in EquityIndex for equity " << eqCurve->name());
298 } else {
299
300 if (!eqCurrency.empty())
301 QL_REQUIRE(eqCurve->currency() == eqCurrency,
302 "Equity Currency provided does not match currency of Equity Curve");
303 else
304 eqCurrency = eqCurve->currency();
305 }
306
307 QuantLib::ext::shared_ptr<QuantExt::FxIndex> fxIndex = nullptr;
308
309 if (!eqCurrency.empty() && dataCurrency != eqCurrency) {
310 QL_REQUIRE(eqData->fxIndex() != "",
311 "No FxIndex - if equity currency differs from leg currency an FxIndex must be provided");
312
313
314
315 if (!eqCurve->currency().empty() && !eqCurrency.empty()) {
316 QL_REQUIRE(eqCurve->currency() == eqCurrency,
317 "Equity Currency provided does not match currency of Equity Curve");
318 }
319
320 fxIndex =
buildFxIndex(eqData->fxIndex(),
data.currency(), eqCurrency.code(), engineFactory->market(),
321 configuration, useXbsCurves);
322 }
323
324 Leg result =
makeEquityLeg(data, eqCurve, fxIndex, openEndDateReplacement);
326 return result;
327}
Currency parseCurrencyWithMinors(const string &s)
Convert text to QuantLib::Currency.
#define WLOG(text)
Logging Macro (Level = Warning)
void addToRequiredFixings(const QuantLib::Leg &leg, const QuantLib::ext::shared_ptr< FixingDateGetter > &fixingDateGetter)
Leg makeEquityLeg(const LegData &data, const QuantLib::ext::shared_ptr< EquityIndex2 > &equityCurve, const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &fxIndex, const QuantLib::Date &openEndDateReplacement)
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)