29 std::vector<Date>& skippedDates,
30 std::vector<std::string>& skippedDatesErrorMessage,
31 const Date& startDate,
34 const std::vector<ext::shared_ptr<InterestRateIndex> >& indexes) {
37 skippedDatesErrorMessage.clear();
39 Size nRates = indexes.size();
40 statistics.
reset(nRates);
42 std::vector<Rate> sample(nRates);
43 std::vector<Rate> prevSample(nRates);
44 std::vector<Rate> sampleDiff(nRates);
46 Calendar cal = indexes[0]->fixingCalendar();
51 for (; currentDate<=endDate;
55 for (
Size i=0; i<nRates; ++i) {
56 Rate fixing = indexes[i]->fixing(currentDate,
false);
59 }
catch (std::exception& e) {
60 skippedDates.push_back(currentDate);
61 skippedDatesErrorMessage.emplace_back(e.what());
68 for (
Size i=0; i<nRates; ++i)
69 sampleDiff[i] = sample[i]/prevSample[i] -1.0;
71 statistics.
add(sampleDiff.begin(), sampleDiff.end());
77 std::swap(prevSample, sample);
83 ext::shared_ptr<SequenceStatistics> stats,
84 const Date& startDate,
87 const std::vector<ext::shared_ptr<InterestRateIndex> >& indexes)
88 : stats_(
std::move(stats)) {
92 startDate, endDate, step,
Date advance(const Date &, Integer n, TimeUnit unit, BusinessDayConvention convention=Following, bool endOfMonth=false) const
Statistics analysis of N-dimensional (sequence) data.
void add(const Sequence &sample, Real weight=1.0)
void reset(Size dimension=0)
std::vector< Date > skippedDates_
ext::shared_ptr< SequenceStatistics > stats_
std::vector< std::string > skippedDatesErrorMessage_
HistoricalRatesAnalysis(ext::shared_ptr< SequenceStatistics > stats, const Date &startDate, const Date &endDate, const Period &step, const std::vector< ext::shared_ptr< InterestRateIndex > > &indexes)
std::size_t Size
size of a container
Statistical analysis of historical rates.
base class for interest rate indexes
void historicalRatesAnalysis(SequenceStatistics &statistics, std::vector< Date > &skippedDates, std::vector< std::string > &skippedDatesErrorMessage, const Date &startDate, const Date &endDate, const Period &step, const std::vector< ext::shared_ptr< InterestRateIndex > > &indexes)