@@ -418,21 +418,23 @@ void runCoreEngine(const boost::shared_ptr<ore::data::Portfolio>& portfolio,
418418 size_t j = 0 ;
419419 for (size_t i = 0 ; i < pathTimes.size (); ++i) {
420420 allTimes.push_back (i);
421- auto & d = dates[i];
422- if (grid->isValuationDate ()[i]) {
423- valuationTimeIdx.push_back (i);
424- auto closeOutDate = grid->closeOutDateFromValuationDate (d);
425- while (j < pathTimes.size () && dates[j] != closeOutDate) {
426- ++j;
421+ if (sgd->withCloseOutLag ()) {
422+ auto & d = dates[i];
423+ if (grid->isValuationDate ()[i]) {
424+ valuationTimeIdx.push_back (i);
425+ auto closeOutDate = grid->closeOutDateFromValuationDate (d);
426+ while (j < pathTimes.size () && dates[j] != closeOutDate) {
427+ ++j;
428+ }
429+ QL_REQUIRE (j < pathTimes.size (),
430+ " AmcValuationEngine:: couldnt find close out date" << to_string (closeOutDate));
431+ closeOutTimeIdx.push_back (j);
427432 }
428- QL_REQUIRE (j < pathTimes.size (), " couldnt find close out date" );
429- closeOutTimeIdx.push_back (j);
430433 }
431434 }
435+ // loop over amc calculators, get result and populate cube
432436
433- // loop over amc calculators, get result and populate cube
434-
435- timer.start ();
437+ timer.start ();
436438 for (Size j = 0 ; j < amcCalculators.size (); ++j) {
437439 auto resFee = feeContributions (j, sgd, model->irModel (0 )->termStructure ()->referenceDate (),
438440 outputCube->samples (), tradeFees, model, fxBuffer, irStateBuffer);
0 commit comments