FixedLocalVolSurface::FixedLocalVolSurface( const Date& referenceDate, const std::vector<Time>& times, const std::vector<Real>& strikes, const boost::shared_ptr<Matrix>& localVolMatrix, const DayCounter& dayCounter, Extrapolation lowerExtrapolation, Extrapolation upperExtrapolation) : LocalVolTermStructure( referenceDate, NullCalendar(), Following, dayCounter), maxDate_(time2Date(referenceDate, dayCounter, times.back())), times_(times), localVolMatrix_(localVolMatrix), strikes_(times.size(),boost::make_shared<std::vector<Real> >(strikes)), localVolInterpol_(times.size()), lowerExtrapolation_(lowerExtrapolation), upperExtrapolation_(upperExtrapolation) { QL_REQUIRE(times_[0]>=0, "cannot have times[0] < 0"); checkSurface(); setInterpolation<Linear>(); }
bool TimeRange::isInSameRange( const DateTime& start, const DateTime& end, const DateTime& time1, const DateTime& time2 ) { if( !isInRange( start, end, time1 ) ) return false; if( !isInRange( start, end, time2 ) ) return false; if( time1 == time2 ) return true; if( start < end || start == end ) { UtcDate time1Date( time1 ); UtcDate time2Date( time2 ); return time1Date == time2Date; } else { int sessionLength = DateTime::SECONDS_PER_DAY - (start - end); if( time1 > time2 ) { UtcTimeOnly time2TimeOnly = UtcTimeOnly(time2); long delta = time2TimeOnly - start; if( delta < 0 ) delta = DateTime::SECONDS_PER_DAY - labs(delta); return (time1 - time2) < (sessionLength - delta); } else { return (time2 - time1) < sessionLength; } } }