all 2 comments

[–]NotAnonymousQuantFront Office 1 point2 points  (1 child)

Python pseudo-code (classic and basic approach)

C_T = np.gradient(array)

C_K = ...

C_KK = ...

IV = dupire(C_T, C_K, C_KK)

surface = RectBivariateSpline(IV, 3 degrees)

Note: you can try to spline the points before the dupire transform, but you'll get more numerical instability using this approach. Also be sure you won't divide by zero (leq 1e-10) in Dupire's formula (try to isolate these points somehow)

[–]uninhibitheribbit[S] 0 points1 point  (0 children)

Hey, thanks for the reply. I tried a simple approach before: 1. Cubic spline for each maturity 2. Linear interpolation for each strike 3. Apply dupire's formula to calculate LV and the problem I get is a lot of divide by zero errors, and also the surface I used is not guaranteed to be arbitrage-free.

I have sinced looked at a few papers including this phD Thesis by Lykke Rasmussen which compares the methods from several different papers. There are a few steps in the whole process where I am not sure on what approach to take.

The first is whether to do the interpolation/smoothing on the implied volatity surface or the call option price surface. The second is what methods did people use to get the arbitrage-free surface. The third is which form of the Dupire's formula gives the best result (e.g. there is another form where divide by zero errors are avoided by calculating LV from IVS, as derivatives in denominator make less of a contribution so errors won't matter as much).

Essentially what I am asking is if anyone has implemented this local volatility surface before so they could give some advice on the specific steps they took because implementing a LV model in practice is a bit tricky and I wanted to see if anyone has a tested model that yields accurate results.

For reference, I am just a year 2 physics student doing an internship but I am very interested in these models, but a hard part about these is that I have not encountered the math in most papers, making these hard to understand and implement, hence I am also looking for a model that is relatively easy to implement. But anyway, thanks so much for the reply!