# QuantLib: Indices

An index is a value of a hypothetical portfolio or, more generally, a statistical measure for a collection of data points. Indices are usually fixed at specific dates. Individual fixings can be thought of as date-value pairs. In an abstract way indices are very much like time series with the difference that the dates of the fixings are restricted. The Index class acts as an abstract base for all index classes defined in QuantLib. Two abstract methods provide basic information and about the index.

virtual std::string name() const = 0;
virtual Calendar fixingCalendar() const = 0;

name() should return the name of the index. The name is used for user output and can be used for comparing different indices but it shouldn’t be used in switch like if statements because the names of indices are not guaranteed to stay the same between versions of QuantLib. The fixingCalendar() method should return the calendar which is used to decide if a given day is a holiday and helps deciding of a date is a valid fixing date. This decision is carried out by the following method.

virtual bool isValidFixingDate(const Date& fixingDate) const = 0;

The method isValidFixingDate() should return true if the date passed to it can be used as a fixing date, that is whether a foxing can be made on that specific date. The central method of Index, which has to be implemented by a concrete class, is the fixing() method.

virtual Real fixing(const Date& fixingDate,
bool forecastTodaysFixing = false) const = 0;

This method should return a number corresponding to the fixing date. For dates before the current evaluation date This method usually returns one of the fixings that have been added manually yo the index. For dates after the evaluation date some forecast has to be made. If the fixing date is requested for the evaluation date then a forecast should be attempted only if the optional flag forecastTodaysFixing has been set to true.

The following method are used to manually add fixings to the index.

virtual void addFixing(const Date& fixingDate,
Real fixing,
bool forceOverwrite = false);

template<class DateIterator, class ValueIterator>
bool forceOverwrite = false);
const TimeSeries<Real>& timeSeries();
void clearFixings();