@@ -572,15 +572,36 @@ void TRS::build(const boost::shared_ptr<EngineFactory>& engineFactory) {
572572 DLOG (" add required fixings for fundings legs with daily resets (if any)" );
573573
574574 for (Size i = 0 ; i < fundingLegs.size (); ++i) {
575- if (fundingNotionalTypes[i] != TRS::FundingData::NotionalType::DailyReset)
576- continue ;
577- for (auto const & c : fundingLegs[i]) {
578- if (auto cpn = boost::dynamic_pointer_cast<QuantLib::Coupon>(c)) {
579- QL_REQUIRE (boost::dynamic_pointer_cast<QuantLib::FixedRateCoupon>(c),
580- " daily reset funding legs support fixed rate coupons only" );
581- for (QuantLib::Date d = cpn->accrualStartDate (); d < cpn->accrualEndDate (); ++d) {
575+ if (fundingNotionalTypes[i] == TRS::FundingData::NotionalType::DailyReset) {
576+ for (auto const & c : fundingLegs[i]) {
577+ if (auto cpn = boost::dynamic_pointer_cast<QuantLib::Coupon>(c)) {
578+ QL_REQUIRE (boost::dynamic_pointer_cast<QuantLib::FixedRateCoupon>(c),
579+ " daily reset funding legs support fixed rate coupons only" );
580+ for (QuantLib::Date d = cpn->accrualStartDate (); d < cpn->accrualEndDate (); ++d) {
581+ for (Size j = 0 ; j < underlying_.size (); ++j) {
582+ Date fixingDate = underlyingIndex[j]->fixingCalendar ().adjust (d, Preceding);
583+ for (auto const & [n, _] : indexNamesAndQty)
584+ requiredFixings_.addFixingDate (fixingDate, n, cpn->date ());
585+ for (auto const & n : fxIndices) {
586+ requiredFixings_.addFixingDate (n.second ->fixingCalendar ().adjust (fixingDate, Preceding),
587+ n.first , cpn->date ());
588+ }
589+ }
590+ }
591+ }
592+ }
593+ } else if (fundingNotionalTypes[i] == TRS::FundingData::NotionalType::PeriodReset) {
594+ for (auto const & c : fundingLegs[i]) {
595+ if (auto cpn = boost::dynamic_pointer_cast<QuantLib::Coupon>(c)) {
582596 for (Size j = 0 ; j < underlying_.size (); ++j) {
583- Date fixingDate = underlyingIndex[j]->fixingCalendar ().adjust (d, Preceding);
597+ Date fundingStartDate = cpn->accrualStartDate ();
598+ Size currentIdx = std::distance (valuationDates.begin (),
599+ std::upper_bound (valuationDates.begin (),
600+ valuationDates.end (),
601+ fundingStartDate + fundingData_.fundingResetGracePeriod ()));
602+ if (currentIdx > 0 )
603+ --currentIdx;
604+ Date fixingDate = valuationDates[currentIdx];
584605 for (auto const & [n, _] : indexNamesAndQty)
585606 requiredFixings_.addFixingDate (fixingDate, n, cpn->date ());
586607 for (auto const & n : fxIndices) {
0 commit comments