[R-SIG-Finance] Pricing option using Explicit Finite Difference method
Joseph Khalil
joedtka at yahoo.com
Tue Jul 17 15:56:20 CEST 2007
I am a new user of R and new to this mailing list. I am using
the book "Implementing Derivatives Models" by Les Clewlow and Chris
Strickland, and I am trying to simulate
the example on pricing options using the explicit finite difference
method in chapter 3. I have tried the following to price plain European calls but I am getting errors.
K<-100 #Strike price
T<-1 #Time of maturity
t<-0 #Current time
sigma<-0.2 #Volatility
r<-0.06 #Interest rate
div<-0.03 # Dividend yield
S<-100 #Central stock price
dx<-0.02 #Space step around central asset price (logarithmic measurement exp(dx))
Nj<-30 #Number of space steps
N<-500 #Number of time steps until T
dt<-T/N # Time step
nu<-r-div-0.5*sigma^2
pu<-0.5*dt*((sigma/dx)^2+nu/dx) # Probability for go up
pm<-1-dt*(sigma/dx)^2-r*dt # Probability for stay the same
pd<-0.5*dt*((sigma/dx)^2-nu/dx) # Probability for go down
# Initialise matrices
St<-matrix(data=0,nrow=2*Nj+1,ncol=1)
Call<-matrix(data=0,nrow=2*Nj+1,ncol=N+1)
#Compute independent values
for (j in (-Nj:Nj)) {
St[Nj-j+1,1]<-S*exp(j*dx) # Initialise asset prices at maturity
Call[Nj-j+1,N+1]<-max(0,St[Nj-j+1,1]-K) } # Initialise option prices at maturity
#Compute dependent option values
for (i in (N:1)) {
# Explicit compution of option values (backwards)
for (j in (-Nj+1:Nj-1)) {
Call[j+Nj+1,i]<-as.matrix(pu*(as.matrix(Call[j+Nj,i+1])))+as.matrix(pm*Call[j+Nj+1,i+1])+as.matrix(pd*Call[j+Nj+2,i+1])
}
Call[1,i]<-Call[2,i]+St[1,1]-St[2,1] # Upper boundary condition
Call[2*Nj+1,i]<-Call[2*Nj,i] #Lower boundary condition
}
----- Original Message ----
From: Joseph Khalil <joedtka at yahoo.com>
To: r-sig-finance at stat.math.ethz.ch
Sent: Monday, July 16, 2007 10:01:27 PM
Subject: [R-SIG-Finance] Pricing option using Explicit Finite Difference method
Hi,
Does anyone have R code to calculate option prices (European, plain vanilla) using Explicit Finite
Difference method?
Thanks,
Joe
_______________________________________________
R-SIG-Finance at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
More information about the R-SIG-Finance
mailing list