@@ -176,7 +176,8 @@ TradeCashflowReportData getCashflowReportData(
176176 const std::string ccy, const Date asof, const ext::shared_ptr<YieldTermStructure>& discountCurveCcy,
177177 const double fxCcyBase,
178178 const std::function<ext::shared_ptr<SwaptionVolatilityStructure>(const std::string& qualifier)>& swaptionVol,
179- const std::function<ext::shared_ptr<OptionletVolatilityStructure>(const std::string& qualifier)>& capFloorVol) {
179+ const std::function<ext::shared_ptr<OptionletVolatilityStructure>(const std::string& qualifier)>& capFloorVol,
180+ const std::string& overwriteFlowType, const Real overwriteNotional) {
180181
181182 QL_REQUIRE (ptrFlow, " getCashflowReportData: prtFlow is null." );
182183 QL_REQUIRE (discountCurveCcy || ptrFlow->hasOccurred (asof), " getCashflowReportData: discountCurveCcy is null." );
@@ -305,6 +306,7 @@ TradeCashflowReportData getCashflowReportData(
305306 fixingDate = ptrIndCf->fixingDate ();
306307 fixingValue = ptrIndCf->indexFixing ();
307308 flowType = " Index" ;
309+ // notional = ptrIndCf->notional(); // TODO we should enable this
308310 } else if (ptrCommIndCf) {
309311 fixingDate = ptrCommIndCf->lastPricingDate ();
310312 fixingValue = ptrCommIndCf->fixing ();
@@ -341,7 +343,7 @@ TradeCashflowReportData getCashflowReportData(
341343 if (amount != Null<Real>())
342344 effectiveAmount = amount * multiplier;
343345
344- discountFactor = ptrFlow-> hasOccurred ( asof) ? 0.0 : discountCurveCcy->discount (payDate);
346+ discountFactor = payDate < asof ? 0.0 : discountCurveCcy->discount (payDate);
345347 if (effectiveAmount != Null<Real>())
346348 presentValue = discountFactor * effectiveAmount;
347349 try {
@@ -443,8 +445,10 @@ TradeCashflowReportData getCashflowReportData(
443445
444446 TradeCashflowReportData result;
445447
448+ Real effNotional = overwriteNotional != Null<Real>() ? overwriteNotional : notional;
449+
446450 result.payDate = payDate;
447- result.flowType = flowType;
451+ result.flowType = overwriteFlowType. empty () ? flowType : overwriteFlowType ;
448452 result.amount = effectiveAmount;
449453 result.currency = ccy;
450454 result.coupon = coupon;
@@ -454,7 +458,7 @@ TradeCashflowReportData getCashflowReportData(
454458 result.accruedAmount = accruedAmount * (accruedAmount == Null<Real>() ? 1.0 : multiplier);
455459 result.fixingDate = fixingDate;
456460 result.fixingValue = fixingValue;
457- result.notional = notional * (notional == Null<Real>() ? 1.0 : multiplier);
461+ result.notional = effNotional * (effNotional == Null<Real>() ? 1.0 : multiplier);
458462 result.discountFactor = discountFactor;
459463 result.presentValue = presentValue;
460464 result.fxRateLocalBase = fxCcyBase;
@@ -478,12 +482,16 @@ std::vector<TradeCashflowReportData> getCashflowReportData(
478482 const std::function<QuantLib::ext::shared_ptr<QuantLib::SwaptionVolatilityStructure>(const std::string& qualifier)>&
479483 swaptionVol,
480484 const std::function<
481- QuantLib::ext::shared_ptr<QuantLib::OptionletVolatilityStructure>(const std::string& qualifier)>& optionletVol) {
485+ QuantLib::ext::shared_ptr<QuantLib::OptionletVolatilityStructure>(const std::string& qualifier)>& optionletVol,
486+ const std::vector<std::string>& overwriteFlowType, const std::vector<Real>& overwriteNotional) {
482487 std::vector<TradeCashflowReportData> result;
483488 for (Size i = 0 ; i < legs.size (); ++i) {
489+ std::string owFlowType = overwriteFlowType.size () > i ? overwriteFlowType[i] : std::string ();
490+ Real owNotional = overwriteNotional.size () > i ? overwriteNotional[i] : Null<Real>();
484491 for (Size j = 0 ; j < legs[i].size (); ++j) {
485492 result.push_back (getCashflowReportData (legs[i][j], payer[i], multiplier[i], baseCcy, ccys[i], asof,
486- discountCurvesCcy[i], fxCcyBase[i], swaptionVol, optionletVol));
493+ discountCurvesCcy[i], fxCcyBase[i], swaptionVol, optionletVol,
494+ owFlowType, owNotional));
487495 result.back ().cashflowNo = j + 1 ;
488496 result.back ().legNo = i;
489497 }
0 commit comments