I am trying to fit a volatility surface using the OG-Analytics library.
After trying around with some data I can’t receive robust results, since most time there is an error with the NonLinearLeastSquare function. Can someony help my? Here is my code: https://github.com/scopederivatives/SABRTest/blob/master/VolSurf.java
Ok I just made a workaround by increasing the MAX_ATTEMOTS in the NonLinearLeastSquare class from 10,000 to 1,000,000 (or higher). But I think, it is not intented to loop that long? Especially if considering, that the DataBundle is pretty small.
The SmileInterpolatorSABR works by fitting sub-smiles to consecutive sets of strike triplets. The SABR model (like all stochastic vol models) will always imply leptokurtic log-returns, which means it is not possible to produce a frown (the implied volatility falling for OTM strikes).
Your data shows many cases where the SABR model simply will not fit. What happens is the the optimiser spends huge amounts of time searching parameter space, before either giving the best (but very poor) fit with crazy parameters or hitting the iteration limit.
Real data (from data providers) can be like this (from a combination of liquidity effects and, often, misentry of the data). Firm spend a lot of time ‘cleaning up’ the data. We don’t have a data clean algorithm in the open-source, but you can see the problems if you plot the data in Excel.
Thank you very much Richard for your explanation!
So is there maybe another method or alternative to construct a smooth volatility surface? Or is it the only way to code a “data clean” algorithm and then smooth the volatility surface?
An outline for a data cleaning algorithm would be the following:
for each expiry fit a smile model (SABR, Heston, SVI etc) to you data by minimizing the sum of squares between market and model volatilities
If the chi-squared is acceptable, stop, otherwise remove the worst point and repeat step 1
This should allow you to detect and remove bad data point automatically. Look at SmileModelFitter as a starting point.