Purpose
- The package "Ruby" provides a fast method based on numerical PDEs for evaluating European put options under the Merton's jump diffusion. It uses a new modal spectral element method in the 1-D semi-unbounded space and a Crank-Nicolson Leap-frog scheme in time. The underline space module is inherited from the package "Sea".
Specifications
- Name: Ruby.
- Author: Feng Chen.
- Finishing date: 06/02/2011.
- Languages: Fortran 90, MATLAB.
- Required libraries: BLAS, LAPACK.
Simple Example
- Equation:
vτ=σ2S22vSS+(r−λκ)SvS−(r+λ)v+λ∫∞0v(ηS,τ)G(η)dη,where (x,τ)∈(0,∞)×(0,T),G(η)=1√2πδηe−(lnη−m)22δ2.
- Initial condition:
v(S,0)=max{K−S,0}.
- Parameters:
T=0.25,K=100,r=0.05,σ=0.15,λ=0.1,δ=0.45,m=−0.9.
Quick Start
- Compiling and running:
cd ./Ruby make library ifort tst_Ruby.f90 -llibrary -llapack -lblas ./a.out matlab plot_Ruby.m
- Graphics:
The exact solution (blue lines) and the numerical solution (red dots) of the put option, its gamma, and its delta are shown against the stock price.
References
- Feng Chen, Jie Shen, and Haijun Yu. A new spectral element method for pricing European options under the Black-Scholes and Merton jump diffusion models, Journal of Scientific Computing, Volume 52, Number 3, 499-518, (2012).
Code Highlights
!> !! Exact evaluation of a Merton put option; !! For comparing the numerical solution. !< function Merton_put(m, tau, s, K, r, & sigma, lambda, delta, mean) result(y) ! number of evaluations integer, intent(in) :: m ! terminal time real(kind=8), intent(in) :: tau ! strike price real(kind=8), intent(in) :: K ! interest rate real(kind=8), intent(in) :: r ! dividend real(kind=8), intent(in) :: sigma ! jump intensity real(kind=8), intent(in) :: lambda ! jump variance real(kind=8), intent(in) :: delta ! jump mean real(kind=8), intent(in) :: mean ! stock prices real(kind=8), intent(in), dimension(m) :: s ! option prices real(kind=8), dimension(m) :: y ! shifted mean real(kind=8) :: kappa ! log kappa real(kind=8) :: vgamma ! shifted rate real(kind=8) :: rm ! each BS option in the summatino real(kind=8) :: each ! shifted jump intensity real(kind=8) :: lambdap ! shifted jump variance real(kind=8) :: sigmam ! temporary variables real(kind=8) :: temp, temp2 integer :: i, n kappa = exp(mean+delta*delta/2d0)-1d0 vgamma = log(1d0+kappa) rm = 0d0 each = 0d0 n = 0 sigmam = 0d0 lambdap = lambda * (1d0 + kappa) temp = 0d0 temp2 = 0d0 y = 0d0 do i = 1, m ! evaluate each option do n = 0, 30 ! cut the series to item 30 rm = r - lambda*kappa + n*vgamma/tau sigmam = sqrt(sigma*sigma + n*delta*delta/tau) temp = -lambdap*tau + n*log(lambdap*tau) - sum_log(n) each = exp(temp) ! evaluation based on the BS option each = each * BS_put_generic(tau, s(i), K, rm, sigmam) ! accumulated sum y(i) = y(i) + each end do end do end function Merton_put
No comments:
Post a Comment