Re: evaluationDate problem (MAJOR CHANGED and solved)
Posted by Stefano Portolan on
URL: http://quantlib.414.s1.nabble.com/evaluationDate-problem-tp16184p16185.html
Hello everybody,
After one day long in the fight I understood that my problem WAS NOT what I thought and wrote.
Excuse for this.
Besides, understanding my problem I found out the answer and I would like to put it here, maybe it will be useful for the other users.
I will probably use inexact informatics wording. Anyone who wants to put forward good knowledge, please take a sit.
My problem was related to the singleton (static … ok, almost) nature of the class where valuationDate_ resides.
When I link my DLL library to my main(), I have 2 environments of static variables : one for the DLL and the other for the main().
When I write inside the DLL, (method Session::valuationDateDLL(valuationDate) )
QuantLib::Settings::instance().evaluationDate() = valuationDate;
I am setting the valuationDate_ of the DLL.
So far so good,
but for some reasons which still are a little bit out of my knowledge, everything you write in the .hpp and not in the .cpp (as template methods) is linked/compiled/attached to the main() and sees the main() environment!
I solved my problem in setting TWICE my evaluation date:
(1) once in the main():
QuantLib::Date valuationDate(30, QuantLib::October, 2014);
QuantLib::Settings::instance().evaluationDate() = valuationDate;
(2) And once in the DLL:
Session::setValuationDateDLL(valuationDate) ;
Like this when I call QuantLib methods in the .cpp’s of my DLL I see (2), when I call QuantLib methods inside my template methods which is in the .hpp I see (1).
Now that the two instances (if I can call them like this) are consistent and my simulation is consistent as well.
Any sensible explanation clearer than mine from some wiser QuantLib users or informatics guru is more than welcome.
Cheers.
Stefano