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();
40 std::move(fixingCalendar),
52 : name_(
std::move(name)), fixingCalendar_(
std::move(fixingCalendar)),
53 currency_(
std::move(currency)), interest_(
std::move(interest)),
54 dividend_(
std::move(dividend)), spot_(
std::move(spot)) {
69 if (fixingDate > today || (fixingDate == today && forecastTodaysFixing))
78 if (fixingDate == today && !
spot_.empty())
81 return spot_->value();
83 QL_FAIL(
"Missing " <<
name() <<
" fixing for " << fixingDate);
88 "null interest rate term structure set to this instance of " <<
name());
Date adjust(const Date &, BusinessDayConvention convention=Following) const
Base class for equity indexes.
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_
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
Currency currency() const
The index currency.
Handle< YieldTermStructure > interest_
EquityIndex(std::string name, Calendar fixingCalendar, Currency currency, Handle< YieldTermStructure > interest={}, Handle< YieldTermStructure > dividend={}, Handle< Quote > spot={})
Real fixing(const Date &fixingDate, bool forecastTodaysFixing=false) const override
returns the fixing at the given date
Shared handle to an observable.
ext::shared_ptr< Observable > notifier() const
virtual Real pastFixing(const Date &fixingDate) const
returns a past fixing at the given date
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