Re: Efficient way to change option inputs over time

Posted by Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/Efficient-way-to-change-option-inputs-over-time-tp15525p15528.html

I do what you're after (i.e., changing the evaluation date and seeing
a different value) in the middle of this screencast:
<http://vimeo.com/92785062>.

The fact that it doesn't work for you might have to do with the way
you setup your term structures. I (still) don't have a screencast for
that :) But in short, if you create your term structures by passing an
explicit reference date, they will remain fixed; if you create them
with an offset in days (possibly null) they will move with the
evaluation date. Depending on the particular term-structure class
you're using, there might be constructors for either case.

Also, you don't need to do the registering yourself. If you set up the
term structures correctly, they are already registered with the
evaluation date and will forward notifications to the pricing engine
and the instrument. Again, the screencast should help.

Luigi


On Fri, Jun 20, 2014 at 2:11 PM, George Cowie <[hidden email]> wrote:

>
>   I have a long history of option prices and I've been using QuantLib to
> back out the implied volatility and then produce the major greeks.  This
> works fine, but I'm finding my code is pretty slow (I know that's
> subjective).  I end up instantiating a new BlackScholesMertonProcess,
> DividendVanillaOption, etc for every option each day, which I think is part
> of the problem.  I thought it might be faster to price the same option over
> time (e.g. loop over days then strikes, instead of looping over strikes then
> days).  Looking over the documentation, I don't think I'm leveraging the
> full Observer/Observable functionality.
>
>   To try and put this into a simple example, what would be an efficient way
> to calculate an option price over a vector of evaluationDates?  I would
> think something like this would be the right approach, but it doesn't seem
> to have an effect on the option value (get same value for all days)
>
>   ...
>
>   UnitedStates calendar(UnitedStates::NYSE);
>   americanOption->registerWith(Settings::instance().evaluationDate()) ;
>
>   while(todaysDate <= expiryDate)
>     {
>       Settings::instance().evaluationDate() = todaysDate;
>       cout << todaysDate << " : " << americanOption->NPV() << endl ;
>       todaysDate = calendar.advance(todaysDate, 1 * Days) ;
>
>     }
>
>   Even if the above code did have the desired effect, I would still need to
> adjust the IV, rates, etc.  Are there examples available for adjusting the
> inputs for an option price?  I can post the full code, but I suspect my
> understanding of the library is the problem here.
>
> Thanks,
> George
>
> ------------------------------------------------------------------------------
> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
> Find What Matters Most in Your Big Data with HPCC Systems
> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
> http://p.sf.net/sfu/hpccsystems
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users