This blog post may help
http://implementingquantlib.blogspot.com/2014/05/chapter-6-part-3-of-8-black-scholes.html
As mentioned
“Using
apply, the
evolve method performs an exponentiation at each step; but above
all, the drift and
diffusion methods repeatedly ask term structures for values. If you
remember
this post, this means going through at least a couple of levels of virtual method calls, sometimes (if we're particularly unlucky) retrieving a rate from discount factors that were obtained from the same rate to begin with.”
Updating the various term structures and dividend class does involve observer, particularly if everyone properly registers themselves to receive updates. Perhaps
sending the right updates will dirty the NPV calculation and result in a recalculation upon the next call (lazy evaluation). That’s what I would expect.
I suspect what you want to do is already possible in QuantLib.
Dale Smith, Ph.D.
Senior Financial Quantitative Analyst
Financial & Risk Management Solutions
Fiserv
Office: 678-375-5315
From: George Cowie [mailto:[hidden email]]
Sent: Friday, June 20, 2014 8:12 AM
To: QuantLib users
Subject: [Quantlib-users] Efficient way to change option inputs over time
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
| Free forum by Nabble | Edit this page |