http://quantlib.414.s1.nabble.com/Efficient-way-to-change-option-inputs-over-time-tp15525.html
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
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.