29 QL_REQUIRE(dates.size() % 2 == 0,
"TimePeriod: dates size must be an even number, got " << dates.size());
30 for (Size i = 0; i < dates.size(); ++i) {
32 Date sDate = dates[i];
33 if (!
calendar.empty() && mporDays != QuantLib::Null<Size>())
34 sDate =
calendar.advance(sDate, -mporDays * QuantLib::Days);
52 out << QuantLib::io::iso_date(t.
startDates()[i]) <<
" to " << QuantLib::io::iso_date(t.
endDates()[i]);
60 vector<Date> allDates;
61 for (
const string& s : timePeriods) {
62 auto dates = parseListOfValues<Date>(s, &
parseDate);
63 for (
const auto& d : dates)
64 allDates.push_back(d);
70 Date maxDate = *std::max_element(period.
endDates().begin(), period.
endDates().end());
72 vector<Date> finalDates;
73 finalDates.push_back(minDate);
74 finalDates.push_back(maxDate);
Handles non-contiguous time period.
TimePeriod(const std::vector< Date > &dates, Size mporDays=QuantLib::Null< Size >(), const QuantLib::Calendar &calendar=QuantLib::Calendar())
std::vector< Date > startDates_
std::vector< Date > endDates_
const std::vector< Date > & endDates() const
const std::vector< Date > & startDates() const
bool contains(const Date &d) const
Size numberOfContiguousParts() const
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
TimePeriod totalTimePeriod(std::vector< std::string > timePeriods, Size mporDays, const QuantLib::Calendar &calendar)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
non-contiguous time period handling