@@ -260,36 +260,36 @@ class ASTIndexExtractor : public AcyclicVisitor,
260260 QL_REQUIRE (v.which () == ValueTypeWhich::Event, " date expected as arg #2 (obsdate)" );
261261 fwdCompAvgEvalDates_[indexName].insert (boost::get<EventVec>(v).value );
262262 }
263+ Date minStart = Date::maxDate ();
264+ Date maxEnd = Date::minDate ();
263265 for (auto const & v : startDateValues) {
264266 QL_REQUIRE (v.which () == ValueTypeWhich::Event, " date expected as arg #3 (startdate)" );
265- for (auto const & w : endDateValues) {
266- QL_REQUIRE (w.which () == ValueTypeWhich::Event, " date expected as arg #4 (enddate)" );
267- Date start = boost::get<EventVec>(v).value ;
268- Date end = boost::get<EventVec>(w).value ;
269- if (start >= end) {
270- continue ;
271- }
272- RandomVariable lookback, fixingDays;
273- for (auto const & l : lookbackValues) {
274- QL_REQUIRE (l.which () == ValueTypeWhich::Number, " number expected as arg #7 (lookback)" );
275- lookback = boost::get<RandomVariable>(l);
276- QL_REQUIRE (lookback.deterministic (), " expected arg #7 (lookback) to be deterministic" );
277- for (auto const & f : fixingDaysValues) {
278- QL_REQUIRE (f.which () == ValueTypeWhich::Number, " number expected as arg #9 (fixingDays)" );
279- fixingDays = boost::get<RandomVariable>(f);
280- QL_REQUIRE (fixingDays.deterministic (), " expected arg #9 (fixingDays) to be deterministic" );
281- // construct template coupon and extract fixing and value dates
282- QuantExt::OvernightIndexedCoupon cpn (
283- end, 1.0 , start, end, on, 1.0 , 0.0 , Date (), Date (), DayCounter (), false , false ,
284- static_cast <Integer>(lookback.at (0 )) * Days, 0 , static_cast <Natural>(fixingDays.at (0 )));
285- fwdCompAvgFixingDates_[indexName].insert (cpn.fixingDates ().begin (),
286- cpn.fixingDates ().end ());
287- DLOG (" adding " << cpn.fixingDates ().size () << " fixing dates for index " << indexName);
288- if (!cpn.valueDates ().empty ()) {
289- fwdCompAvgStartEndDates_[indexName].insert (cpn.valueDates ().front ());
290- fwdCompAvgStartEndDates_[indexName].insert (cpn.valueDates ().back ());
291- }
292- }
267+ minStart = std::min (minStart, boost::get<EventVec>(v).value );
268+ }
269+ for (auto const & w : endDateValues) {
270+ QL_REQUIRE (w.which () == ValueTypeWhich::Event, " date expected as arg #4 (enddate)" );
271+ maxEnd = std::max (maxEnd, boost::get<EventVec>(w).value );
272+ }
273+ if (minStart >= maxEnd)
274+ continue ;
275+ RandomVariable lookback, fixingDays;
276+ for (auto const & l : lookbackValues) {
277+ QL_REQUIRE (l.which () == ValueTypeWhich::Number, " number expected as arg #7 (lookback)" );
278+ lookback = boost::get<RandomVariable>(l);
279+ QL_REQUIRE (lookback.deterministic (), " expected arg #7 (lookback) to be deterministic" );
280+ for (auto const & f : fixingDaysValues) {
281+ QL_REQUIRE (f.which () == ValueTypeWhich::Number, " number expected as arg #9 (fixingDays)" );
282+ fixingDays = boost::get<RandomVariable>(f);
283+ QL_REQUIRE (fixingDays.deterministic (), " expected arg #9 (fixingDays) to be deterministic" );
284+ // construct template coupon and extract fixing and value dates
285+ QuantExt::OvernightIndexedCoupon cpn (
286+ maxEnd, 1.0 , minStart, maxEnd, on, 1.0 , 0.0 , Date (), Date (), DayCounter (), false , false ,
287+ static_cast <Integer>(lookback.at (0 )) * Days, 0 , static_cast <Natural>(fixingDays.at (0 )));
288+ fwdCompAvgFixingDates_[indexName].insert (cpn.fixingDates ().begin (), cpn.fixingDates ().end ());
289+ DLOG (" adding " << cpn.fixingDates ().size () << " fixing dates for index " << indexName);
290+ if (!cpn.valueDates ().empty ()) {
291+ fwdCompAvgStartEndDates_[indexName].insert (cpn.valueDates ().front ());
292+ fwdCompAvgStartEndDates_[indexName].insert (cpn.valueDates ().back ());
293293 }
294294 }
295295 }
0 commit comments