Collocating Local Volatility Model K. Spanderen Uniper Global Commodities QuantLib User Meeting 2016 Düsseldorf 08.12.2016 K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 1 / 30
QuantLib Integration I: Multi-Threading The pricing library is mainly JVM based with QuantLib being integrated via SWIG Hosted in WebContainers on multiple NUMA machines ⇒ Thread-safe code is crucial Communication: JSON or XML via http or WebSockets Do not share QuantLib objects between threads ⇒ use Riccardo’s thread local singleton pattern JVM has multi-threaded garbage collector ⇒ set QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 2 / 30
QuantLib Integration II: Memory Performance Important use case: Large number of parallel pricing via PDE Observation on large NUMA Windows server: Kernel consumes almost all CPU time Many new/delete calls with same array size ⇒ Malloc does not scale Solution: thread local "cache" for Array and Matrix ⇒ released memory is kept in thread local list ⇒ next Array related malloc reuses thread local memory K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 3 / 30
QuantLib Integration III: Garbage Collection Memory Bombshell for ( i < − 0 u n t i l 1000000) new org . quantlib . Array (125000) K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 4 / 30
QuantLib Integration III: Garbage Collection Code sniplet is likely to shutdown your JVM Memory allocated by QuantLib Array is unknown to JVM JVM will not trigger garbage collector even if the OS is already running out of memory Workaround from SWIG manual does not work on recent JVMs Solution from the ’90s for ( i < − 0 u n t i l 10000000) ( new org . quantlib . Array (125000)) delete K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 5 / 30
Introduction: Different View on Calibration Risk neutral pricing with implied probability density function f ( S t , t ) � ∞ V call ( t , K ) = e − rT ( S t − K ) f ( S t , t ) dS t K By differentiation of the equation above, the market implied cumulative distribution function F S t ( s ) is given by � s F S t ( s ) = Prop ( S t ≤ s ) = f ( S t , t ) dS t 0 | K = s = e rt ∂ V put ( t , K ) 1 + e rt ∂ V call ( t , K ) = | K = s ∂ K ∂ K Model calibration: Tune model parameters to match F S t ( s ) . K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 6 / 30
Exact Calibration: Local Volatlility Model In the Local Volatility (LV) model the volatility σ LV ( S , t ) is a function of spot level S t and time t . The dynamics of the spot price is given by: dS t = ( r t − q t ) S t dt + σ LV ( S t , t ) S t dW t � ∂ T + ( r t − q t ) K ∂ C ∂ C ∂ K + q t C � σ 2 LV ( S , t ) = � K 2 ∂ 2 C � � 2 ∂ K 2 K = S , T = t The model is often criticized for its unrealistic volatility dynamics. The Dupire formula is mathematically appealing but also unstable. K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 7 / 30
Lech Grzelak: Collocating Local VolatlilityModel The dynamics of the spot process is given by some kernel process X t and a deterministic mapping function g ( X , t ) such that S t = g ( t , X t ) dX t = µ ( X t , t ) dt + σ ( X t , t ) dW t The mapping function g ( t , x ) is chosen such that the cumulative distribution function (CDF) of S t matches the market implied CDF . The LV model is a special case of the CLV model with g ( t , X t ) ≡ X t µ ( X t , t ) = ( r t − q t ) X t σ ( X t , t ) = σ LV ( X t , t ) X t K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 8 / 30
Collocating Local Volatlility (CLV) Model The choice of the stochastic kernel process X t does not influence the model prices of vanilla European options as they are given by the market implied terminal CDF . The kernel process X t influences the dynamics of the forward volatility skew generated by the model and therefore the prices of exotic options. It is also preferable to choose an analytical trackable process X t to reduce the computational efforts. K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 9 / 30
The Mapping Function g ( t , x ) Define a set of calibration maturities T i , i = 1 , . . . , m Define the set kernel collocation points x i , j = x j ( T i ) , j = 1 , . . . , n having n interpolation points per maturity T i . Define the spot colloation points by s i , j = g ( t i , x i , j ) Calibration: The CDF of X t should match the market implied CDF of S t for all collocation points. � � � � � � F X Ti x i , j = F S Ti s i , j = F S Ti g ( T i , x i , j ) � � F − 1 ⇒ g ( T i , x i , j ) = F X Ti ( x i , j ) S Ti F X Ti is analytically known or easy to compute. F − 1 S Ti ( x ) can be calculated from F S Ti ( s ) via Brent solver. K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 10 / 30
The Mapping Function g ( t , x ) The values of the two dimensional mapping function g ( t , x ) are known for T i and collocation points x i , j with s i , j = g ( t i , x i , j ) . Interpolation scheme: Linear interpolation in t: t − T i � � s j ( t ) = s i , j + s i + 1 , j − s i , j , ∀ t ∈ [ T i , T i + 1 ] T i + 1 − T i Lagrange interpolation in x: N N x ( t ) − x j ( t ) � � g ( t , x ( t )) = s j ( t ) l j ( x ( t )) , l j ( x ( t )) = x k ( t ) − x j ( t ) j = 1 k = 1 , j � = k K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 11 / 30
The Collocation Points Aim: Stable interpolation under the probability distribution X ( t ) E [ S ( T i )] = E [ g ( T i , X ( T i ))] + ǫ Optimal collocation points are the Gauss quadrature abscissæ of the underlying probability distribution of the kernel process X ( t ) . Use the barycentric formulation of the Lagrange interpolation. K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 12 / 30
The Collocation Points Example: e x Lagrange interpolation of f ( x ) = cos ( x ) in x ∈ {− 1 , 1 } Uniform probability distribution ⇒ Gauss-Legendre abscissæ Array x = GaussLegendreIntegration(n).x(); K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 13 / 30
The Normal-CLV Model Choose Ornstein-Uhlenbeck Kernel Process X t = κ ( θ − X t ) dt + σ dW t The exact solution is a normal distribution with , V ar [ X ( t )] = σ 2 E [ X ( t )] = X ( t 0 ) e − κ t + θ � 1 − e − 2 κ t � 1 − e − κ t � � 2 κ Collocation points are therefore given by V ar [ X t ] x N ( 0 , 1 ) � x j ( t ) = E [ X t ] + j with x N ( 0 , 1 ) = x given by the Gauss-Hermite abscissæ j Array x=std::sqrt(2)*GaussHermiteIntegration(n).x(); K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 14 / 30
Pricing under the Normal-CLV Model Once the mapping function g ( t , x ) has been calibrated to the market implied probability distribution pricing is straight forward. Partial Differential Equation (Feynman-Kac): ∂ x + σ 2 ∂ 2 V ∂ V ∂ t + κ ( θ − x ) ∂ V ∂ x 2 − rV = 0 2 V ( T , S ) = Payoff ( g ( T , X ( T )) K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 15 / 30
Normal-CLV: Pricing Error for Vanilla Options Market prices model: S 0 = 100 , r = 0 . 1 , q = 0 . 04 , σ = 0 . 25 , T = 1 Normal-CLV process: κ = 1 . 0 , θ = 0 . 1 , σ = 0 . 5 , x 0 = 0 . 1 , n = 10 K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 16 / 30
Normal-CLV: Forward Volatility Skew Model Setup: Market prices are given by Heston model with S 0 = 100 , r = 0 . 1 , q = 0 . 05 , ν o = 0 . 09 , κ = 1 . 0 , θ = 0 . 06 , σ = 0 . 4 , ρ = − 0 . 75 Normal-CLV process parameters are given by κ = 1 . 0 , θ = 0 . 1 , σ = 0 . 5 , x 0 = 0 . 1 , n = 10 Implied volatility of an forward starting European option with maturity date T 2 six month after the reset date T 1 Payoff = max ( 0 , S T 2 − α S T 1 ) K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 17 / 30
Normal-CLV: Forward Volatility Skew K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 18 / 30
Normal-CLV: Comparison with Heston-SLV Add leverage function L ( S t , t ) and mixing factor η to the Heston Model: � � dt + L ( S t , t ) √ ν t dW S r t − q t − 1 2 L ( S t , t ) 2 ν t d ln S t = t κ ( θ − ν t ) dt + ησ √ ν t dW ν d ν t = t dW ν t dW S ρ dt = t Mixing factor η tunes between stochastic and local volatility. K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 19 / 30
Normal-CLV: Comparison with Heston-SLV K. Spanderen Uniper Global Commodities Collocating Local Volatility Model QuantLib User Meeting 20 / 30
Recommend
More recommend