dynamic time change as in the case of quotes

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

dynamic time change as in the case of quotes

javit
As price quotes change, NPVs change. I would like to change the evaluation time and update the instruments' NPVs similarly. There is a comment in a header file but I couldn't apply it succesfully. Presumably, I should make the evaluation time observable and alert its observers when the value has changed. How do I do this at the highest level in the code without making changes engine by engine? Is it possible at all?

Thank you,
Javit

The comment below is from the settings.hpp:

       //! the date at which pricing is to be performed.
        /*! Client code can inspect the evaluation date, as in:
            \code
            Date d = Settings::instance().evaluationDate();
            \endcode
            where today's date is returned if the evaluation date is
            set to the null date (its default value;) can set it to a
            new value, as in:
            \code
            Settings::instance().evaluationDate() = d;
            \endcode
            and can register with it, as in:
            \code
            registerWith(Settings::instance().evaluationDate());
            \endcode
Reply | Threaded
Open this post in threaded view
|

Re: dynamic time change as in the case of quotes

Luigi Ballabio
On Wed, 2008-09-24 at 07:15 -0700, javit wrote:
> As price quotes change, NPVs change. I would like to change the evaluation
> time and update the instruments' NPVs similarly. There is a comment in a
> header file but I couldn't apply it succesfully. Presumably, I should make
> the evaluation time observable and alert its observers when the value has
> changed. How do I do this at the highest level in the code without making
> changes engine by engine? Is it possible at all?

Is it already done in the existing engines.  You'll have to initialize
any term structures you use (risk-free curves, volatilities, etc.) by
using the constructors taking a calendar and a number of settlement
days, and NOT the constructor taking a fixed reference date.  Term
structures initialized this way register with the evaluation date, and
as the latter changes they recalculate their reference date accordingly.
After doing this, and after having created your instruments and engines,
just change the evaluation date as in:

Settings::instance().evaluationDate() = ...;

and the NPVs will change.

Luigi


--

The purpose of abstraction is not to be vague, but to create a new
semantic level in which one can be absolutely precise.
-- W.E. Dijkstra



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: dynamic time change as in the case of quotes

javit
In reply to this post by javit
It worked.

Thank you,
Javit

javit wrote
As price quotes change, NPVs change. I would like to change the evaluation time and update the instruments' NPVs similarly. There is a comment in a header file but I couldn't apply it succesfully. Presumably, I should make the evaluation time observable and alert its observers when the value has changed. How do I do this at the highest level in the code without making changes engine by engine? Is it possible at all?

Thank you,
Javit

The comment below is from the settings.hpp:

       //! the date at which pricing is to be performed.
        /*! Client code can inspect the evaluation date, as in:
            \code
            Date d = Settings::instance().evaluationDate();
            \endcode
            where today's date is returned if the evaluation date is
            set to the null date (its default value;) can set it to a
            new value, as in:
            \code
            Settings::instance().evaluationDate() = d;
            \endcode
            and can register with it, as in:
            \code
            registerWith(Settings::instance().evaluationDate());
            \endcode