|
Hi all,
a few functions/methods need to know which date it is, or which
date it is supposed to be for calculation purposes---e.g., a LIBOR
index needs to know today's date in order to know whether it should
forecast or look for past fixings; and when adding two Money instances
with different currencies, the current date must be known in order to
look up the correct exchange rate. In the former case, the date
returned by index.termStructure().todaysDate() is used (which, as Nando
pointed out to me, is not fully satisfactory;) in the latter case,
Date::todaysDate() is used (which is even less satisfactory.)
Instead, I'd create some kind of singleton Settings class through which
the global evaluation date can be set and retrieved, as in
Settings::instance().evaluationDate() = Date(30,August,2004);
Date d = Settings::instance().evaluationDate()
The stored date would be used whenever one needs to know what day it's
supposed to be, and the actual today's date would be returned if none
was set. (As a side effect, todaysDate() would eventually disappear
from TermStructure.)
Thoughts?
Later,
Luigi
|