24#include <ql/time/calendars/jointcalendar.hpp>
29 const std::vector<Real>& weights,
30 const std::vector<QuantLib::ext::shared_ptr<FxIndex>>& fxConversion)
31 : name_(name), indices_(indices), weights_(weights), fxConversion_(fxConversion) {
33 <<
") must match weights size ("
36 "CompositeIndex: fx conversion size (" <<
fxConversion_.size() <<
") must match indices size ("
43 std::vector<Calendar> cals;
46 cals.push_back(i->fixingCalendar());
62 for (Size i = 0; i <
indices_.size(); ++i) {
65 indexFixing =
indices_[i]->fixing(fixingDate, forecastTodaysFixing);
66 }
catch (
const std::exception&) {
67 auto gi = QuantLib::ext::dynamic_pointer_cast<QuantExt::GenericIndex>(
indices_[i]);
68 if (gi && gi->expiry() != Date() && fixingDate >= gi->expiry())
75 result += indexFixing *
weights_[i] *
79 forecastTodaysFixing));
85 const Date& today = Settings::instance().evaluationDate();
87 for (Size i = 0; i <
indices_.size(); ++i) {
88 if (
auto ei = QuantLib::ext::dynamic_pointer_cast<EquityIndex2>(
indices_[i])) {
89 for (
auto const& d : ei->dividendFixings()) {
90 if (d.exDate >= startDate && d.exDate <= std::min(endDate, today)) {
105 const Date& endDate) {
107 std::vector<std::pair<QuantLib::Date, std::string>> fixings;
108 const Date& eDate = endDate == Date() ? Settings::instance().evaluationDate() : endDate;
109 for (Size i = 0; i <
indices_.size(); ++i) {
111 Date d =
fxConversion_[i]->fixingCalendar().adjust(startDate, Preceding);
113 fixings.push_back(std::make_pair<Date, std::string>(
bond index class representing historical and forward bond prices
const std::vector< QuantLib::ext::shared_ptr< QuantLib::Index > > & indices() const
Inspectors.
std::vector< QuantLib::ext::shared_ptr< QuantLib::Index > > indices_
std::vector< QuantLib::ext::shared_ptr< FxIndex > > fxConversion_
std::vector< std::pair< QuantLib::Date, std::string > > dividendFixingDates(const Date &startDate, const Date &endDate=Date::maxDate())
Calendar fixingCalendar() const override
const std::vector< QuantLib::ext::shared_ptr< FxIndex > > & fxConversion() const
std::string name() const override
Index interface.
std::vector< Real > weights_
Real dividendsBetweenDates(const Date &startDate, const Date &endDate=Date::maxDate()) const
CompositeIndex(const std::string &name, const std::vector< QuantLib::ext::shared_ptr< QuantLib::Index > > &indices, const std::vector< Real > &weights, const std::vector< QuantLib::ext::shared_ptr< FxIndex > > &fxConversion={})
bool isValidFixingDate(const Date &fixingDate) const override
Real fixing(const Date &fixingDate, bool forecastTodaysFixing=false) const override
index representing a weighted sum of underlying indices
equity index class for holding equity fixing histories and forwarding.
generic index class for storing price histories