Stochastic Local Volatility in Quantlib
Total Page:16
File Type:pdf, Size:1020Kb
Stochastic Local Volatility in QuantLib J. Göttker-Schnetmann, K. Spanderen QuantLib User Meeting 2014 Düsseldorf 2014-12-06 Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 1 / 41 Heston Stochastic Local Volatility Fokker-Planck Equations Square Root Process Boundary Conditions Coordinate and Density Transformations Calibration Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 2 / 41 Local Volatility [Dupire 1994] Local Volatility σLV (S; t) as function of spot level St and time t: 1 d ln S = r − q − σ2 (S; t) dt + σ (S; t)dW t t t 2 LV LV t @C @C + (rt − qt ) K + qt C σ2 (S; t)= @T @K LV K 2 @2C 2 @K 2 K =S;T =t Consistent with option market prices. Model is often criticized for its unrealistic volatility dynamics. Dupire formula is mathematically appealing but also unstable. Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 3 / 41 Stochastic Volatility [Heston 1993] Stochastic volatility given by a square-root process: 1 p d ln S = r − q − ν dt + ν dW S t t t 2 t t t p ν dνt = κ (θ − νt ) dt + σ νt dWt ν S ρdt = dWt dWt Semi-analytical solution for European call option prices: −(rt −qt )T C(S0; K ; ν0; T ) = SP1 − Ke P2 Z 1 " −iu ln K # 1 1 e φj (S0; K ; ν0; T ; u) Pj = + < du 2 π 0 iu More realistic volatility dynamics. Does often not exhibit enough skew for short dated expiries. Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 4 / 41 Example: Differences in δ and γ The implied and local volatility surface is derived from the Heston model and therefore the option prices between all models match. S0 = 5000; κ = 5:66; θ = 0:075; σ = 1:16; ρ = −0:51; ν0 = 0:19; T = 1:7 4 − Black-Scholes 3*10 Heston Heston Mean Variance Local Volatility 0.8 1.0 4 − 2*10 δ γ 4 − Black-Scholes Heston 0.2 0.4 0.6 Heston Mean Variance Local Volatility 0 1*10 2000 3000 4000 5000 6000 7000 8000 2000 3000 4000 5000 6000 7000 8000 Strike Strike Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 5 / 41 Heston Stochastic Local Volatility Add leverage function L(St ; t) and mixing factor η: 1 p d ln S = r − q − L(S ; t)2ν dt + L(S ; t) ν dW S t t t 2 t t t t t p ν dνt = κ (θ − νt ) dt + ησ νt dWt ν S ρdt = dWt dWt Leverage L(xt ; t) is given by probability density p(St ; ν; t) and s R σ (S ; t) + p(St ; ν; t)dν L(S ; t) = LV t = σ (S ; t) R t p LV t R νp(S ; ν; t)dν E[νt jS = St ] R+ t Mixing factor η tunes between stochastic and local volatility. Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 6 / 41 Cheat Sheet: Link between SDE and PDE Starting point is a multidimensional SDE of the form: dxt = µ(xt ; t)dt + σ(xt ; t)dW t Feynman-Kac: price of a derivative u(xt ; t) with boundary condition u(xT ; T ) at maturity T is given by: n n X 1 X T @t u + µi @x u + σσ @x @x u − ru = 0 k 2 kl k l k=1 k;l=1 Fokker-Planck: time evolution of the probability density function p(xt ; t) with the initial condition p(x; t = 0) = δ(x − x0) is given by: n n X 1 X h T i @t p = − @x [µi p] + @x @x σσ p k 2 k l kl k=1 k;l=1 Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 7 / 41 Backward Feynman-Kac Equation The SLV model leads to following Feynman-Kac equation for a function u : R × R≥0 × R≥0 ! R; (x; ν; t) 7! u(x; ν; t): 1 1 0 = @ u + L2ν@2u + η2σ2ν@2u + ησνρL@ @ u t 2 x 2 ν x ν 1 + r − q − L2ν @ u + κ (θ − ν) @ u − ru 2 x ν PDE can be solved using either Implict scheme (slow) or more advanced operator splitting schemes like modified Craig-Sneyd or Hundsdorfer-Verwer in conjunction with damping steps (fast). Implementation is mostly harmless, extend FdmHestonOp. Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 8 / 41 Forward Fokker-Planck Equation The corresponding Fokker-Planck equation for the probability density p : R × R≥0 × R≥0 ! R≥0; (x; ν; t) 7! p(x; ν; t) is: 1 h i 1 @ p = @2 L2νp + η2σ2@2 [νp] + ησρ∂ @ [Lνp] t 2 x 2 ν x ν 1 −@ r − q − L2ν p − @ [κ (θ − ν) p] x 2 ν Numerical solution of the PDE is cumbersome due to difficult boundary conditions and the Dirac delta distribution as the initial condition. PDE can be efficiently solved using operator splitting schemes, preferable the modified Craig-Sneyd scheme Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 9 / 41 Square Root Process Main issues of the implementation are caused by the square root process: p dνt = κ(θ − νt )dt + σ νt dW It has the following Fokker-Planck equation for the probability density p : R≥0 × R≥0 ! R≥0; (ν; t) 7! p(ν; t): σ2 @ p = @2 [νp] − @ [κ(θ − ν)p] t 2 ν ν The stationary probability density p^(ν) with @t p^(ν) = 0 is: 2κθ α p^(ν) = βανα−1 exp(−βν)Γ(α)−1; α = ; β = σ2 θ Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 10 / 41 Stationary Probability Density Stationary Distribution with θ=0.25 8 1 if α < 1 6 < −1 α=2.0 lim p^(ν) = θ if α = 1 α=1.2 ν!0 : α=1.0 0 if α > 1 α=0.5 ) ν 3 4 5 ( ^ The square root process νt p is strictly positive if the Feller Condition α > 1 is met. 0 1 2 0.0 0.2 0.4 0.6 0.8 ν Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 11 / 41 Boundary Condition The probability weight within [νmin; νmax ] of p(ν; t) is evolving by: Z νmax Z νmax 2 σ 2 @t dνp = dν @ν [νp] − @ν [κ(θ − ν)p] νmin νmin 2 In order to avoid leaking of probability we enforce: ν Z νmax 2 max σ @t dνp = 0 ) @ν [νp] − [κ(θ − ν)p] = 0 2 νmin νmin 2 σ ) @ν [νp] − [κ(θ − ν)p] = 0 2 ν=νmin,νmax Zero Flux Boundary Condition Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 12 / 41 Discretization On a non-uniform grid fz1;:::; zng the two-sided approximation of @z f is: 2 2 2 2 hi−i fi+1 + (hi − hi−1)fi − hi fi−1 @z f (zi ) ≈ hi−1hi (hi−1 + hi ) h f − f h f − f = i−1 i+1 i + i i i−1 hi−1 + hi hi hi−1 + hi hi−1 With hi := zi+1 − zi and fi := f (zi ). The second order derivative is approximated by: h f − (h + h )f + h f @2 ( ) ≈ i−i i+1 i−1 i i i i−1 z f zi 1 2 hi−1hi (hi−1 + hi ) Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 13 / 41 Discretization Sort by factors of fi , set ζi := hi hi−1 p ζi := hi (hi−1 + hi ) m ζi := hi−1(hi−1 + hi ) then: h (h − h ) h @ f (z ) ≈ i−i f + i i−1 f − i f z i p i+1 ζ i ζm i−1 ζi i i 2 2 2 @2f (z ) ≈ f − f + f z i p i+1 ζ i ζm i−1 ζi i i Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 14 / 41 Discretization A general partial differential equation of the form 2 @t f = A(z)@z f + B(z)@z f + C(z)f has therefore the spacial discretization: 2A + B h −2A + B (h − h ) @ f (z ) = i i i−i f + i i i i−1 + C f t i p i+1 ζ i i ζi i 2Ai − Bi hi + m fi−1 ζi =: γi fi+1 + βi fi + αi fi−1 Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 15 / 41 Discretization This is interpreted as a tridiagonal transfer matrix T with diagonal βi , upper diagonal γi , and lower diagonal αi : 0 1 β1 γ1 0 ::: Bα β γ 0 ::: C B 2 2 2 C B 0 α β γ 0 ::: C B 3 3 3 C T := B . C B . 0 .. .. .. 0 C B C B . C @ . αn−1 βn−1 γn−1A αn βn Then 0 1 0 1 f1 f1 B . C B . C @t @ . A = T @ . A fn fn Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 16 / 41 Boundary Condition Add z0 below the lower boundary and zn+1 above the upper boundary to the grid. The zero flux condition takes the general form ! [@z A(z; t)f + B(z; t)f ] = 0 z=z0;zn+1 Lower Boundary: The partial derivative is discretized by a second order forward differentiation, so that all terms are given by grid points 2 2 2 2 −h0f2 + (h1 + h0) f1 − ((h1 + h0) − h0)f0 @z f (z0) ≈ h0h1(h1 + h0) h (h + h ) (2h + h ) = − 0 f + 0 1 f − 0 1 f p 2 ζ 1 ζm 0 ζ1 1 1 Göttker-Schnetmann, Spanderen Towards SLV in QuantLib QuantLib User Meeting 17 / 41 Boundary Condition The general zero-flux boundary condition is therefore discretized at the lower boundary as h (h + h ) (2h + h ) 0 = − 0 A f + 0 1 A f + − 0 1 A + B f p 0 2 ζ 0 1 ζm 0 0 0 ζ1 1 1 =: c1f2 + b1f1 + a1f0 c1 b1 ) f0 = − f2 − f1 a1 a1 @t f1 = γ1f2 + β1f1 + α1f0 c1 b1 = (γ1 − α1 )f2 + (β1 − α1 )f1 a1 a1 ! modification of the transfer matrix.