27 Real resolveSpot(
const Handle<Quote>& spot,
Real lastFixing) {
28 QL_REQUIRE(!spot.empty() || lastFixing != Null<Real>(),
29 "Cannot forecast equity index, missing both spot and historical index");
30 return spot.empty() ? lastFixing : spot->value();
39 : name_(
std::move(name)), fixingCalendar_(
std::move(fixingCalendar)),
40 interest_(
std::move(interest)), dividend_(
std::move(dividend)), spot_(
std::move(spot)) {
55 if (fixingDate > today || (fixingDate == today && forecastTodaysFixing))
64 if (fixingDate == today && !
spot_.empty())
67 return spot_->value();
69 QL_FAIL(
"Missing " <<
name() <<
" fixing for " << fixingDate);
79 "null interest rate term structure set to this instance of " <<
name());
Date adjust(const Date &, BusinessDayConvention convention=Following) const
virtual ext::shared_ptr< EquityIndex > clone(const Handle< YieldTermStructure > &interest, const Handle< YieldTermStructure > ÷nd, const Handle< Quote > &spot) const
Calendar fixingCalendar() const override
returns the calendar defining valid fixing dates
virtual Real forecastFixing(const Date &fixingDate) const
It can be overridden to implement particular conventions.
Handle< YieldTermStructure > dividend_
EquityIndex(std::string name, Calendar fixingCalendar, Handle< YieldTermStructure > interest={}, Handle< YieldTermStructure > dividend={}, Handle< Quote > spot={})
virtual Real pastFixing(const Date &fixingDate) const
std::string name() const override
Returns the name of the index.
Handle< Quote > spot() const
index spot value
bool isValidFixingDate(const Date &fixingDate) const override
returns TRUE if the fixing date is a valid one
Handle< YieldTermStructure > interest_
Real fixing(const Date &fixingDate, bool forecastTodaysFixing=false) const override
returns the fixing at the given date
Shared handle to an observable.
const TimeSeries< Real > & timeSeries() const
returns the fixing TimeSeries
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
DateProxy & evaluationDate()
the date at which pricing is to be performed.
static Settings & instance()
access to the unique instance
base class for equity indexes
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
global repository for run-time library settings