@@ -68,22 +68,24 @@ Real McMultiLegBaseEngine::time(const Date& d) const {
6868
6969McMultiLegBaseEngine::CashflowInfo McMultiLegBaseEngine::createCashflowInfo (boost::shared_ptr<CashFlow> flow,
7070 const Currency& payCcy, Real payer,
71- Size legNo, Size cashflowNo ) const {
71+ Size legNo, Size cfNo ) const {
7272
7373 constexpr Real tinyTime = 1E-10 ;
7474
7575 CashflowInfo info;
7676
7777 // set some common info: pay time, pay ccy index in the model, payer, exercise into decision time
7878
79+ info.legNo = legNo;
80+ info.cfNo = cfNo;
7981 info.payTime = time (flow->date ());
8082 info.payCcyIndex = model_->ccyIndex (payCcy);
8183 info.payer = payer;
8284
8385 if (auto cpn = boost::dynamic_pointer_cast<Coupon>(flow)) {
8486 QL_REQUIRE (cpn->accrualStartDate () < flow->date (),
8587 " McMultiLegBaseEngine::createCashflowInfo(): coupon leg "
86- << legNo << " cashflow " << cashflowNo << " has accrual start date (" << cpn->accrualStartDate ()
88+ << legNo << " cashflow " << cfNo << " has accrual start date (" << cpn->accrualStartDate ()
8789 << " ) >= pay date (" << flow->date ()
8890 << " ), which breaks an assumption in the engine. This situation is unexpected." );
8991 info.exIntoCriterionTime = time (cpn->accrualStartDate ()) + tinyTime;
@@ -237,8 +239,7 @@ McMultiLegBaseEngine::CashflowInfo McMultiLegBaseEngine::createCashflowInfo(boos
237239 effectiveRate = RandomVariable (n, ibor->gearing ()) * fixing + RandomVariable (n, ibor->spread ());
238240 }
239241
240- return RandomVariable (states.at (0 ).at (0 )->size (), ibor->nominal () * ibor->accrualPeriod ()) * effectiveRate *
241- fxFixing;
242+ return RandomVariable (n, ibor->nominal () * ibor->accrualPeriod ()) * effectiveRate * fxFixing;
242243 };
243244 return info;
244245 }
@@ -267,7 +268,7 @@ McMultiLegBaseEngine::CashflowInfo McMultiLegBaseEngine::createCashflowInfo(boos
267268 // if (auto cms = boost::dynamic_pointer_cast<CmsCoupon>(flow)) {
268269 // }
269270
270- QL_FAIL (" McMultiLegBaseEngine::createCashflowInfo(): unhandled coupon leg " << legNo << " cashflow " << cashflowNo );
271+ QL_FAIL (" McMultiLegBaseEngine::createCashflowInfo(): unhandled coupon leg " << legNo << " cashflow " << cfNo );
271272} // createCashflowInfo()
272273
273274Size McMultiLegBaseEngine::timeIndex (const Time t, const std::set<Real>& times) const {
@@ -334,10 +335,11 @@ void McMultiLegBaseEngine::calculate() const {
334335
335336 std::vector<CashflowInfo> cashflowInfo;
336337
337- Size legNo = 0 , cashflowNo = 0 ;
338+ Size legNo = 0 ;
338339 for (auto const & leg : leg_) {
339340 Currency currency = currency_[legNo];
340341 Real payer = payer_[legNo];
342+ Size cashflowNo = 0 ;
341343 for (auto const & cashflow : leg) {
342344 // we can skip cashflows that are paid
343345 if (cashflow->date () <= today_)
0 commit comments