Monday 21 January 2019

MC simulation of Black Scholes in R


stock=398.79
sigma=0.32
strike=300
TTM=2.5
rf=0.01
num.sim<-100000
R<-(rf-0.5*sigma^2)*TTM
R
SD<-sigma*sqrt(TTM)
SD
TTM.price<-stock*exp(R+SD*rnorm(num.sim,0,1))
TTM.call<-pmax(0,TTM.price-strike)
PV.call<-TTM.call*(exp(-rf*TTM))
mean(PV.call)
TTM.put<-pmax(0,strike-TTM.price)
PV.put<-TTM.put*(exp(-rf*TTM))
mean(PV.put)
#Let's calculate Black-Scholes value fr call and put option#
d1<-(log(stock/strike)+(rf+0.5*sigma^2)*TTM)/(sigma*sqrt(TTM))
d2<-d1-(sigma*sqrt(TTM))
BS.call<-stock*pnorm(d1,mean=0,sd=1)-strike*exp(-rf*TTM)*pnorm(d2,mean=0,sd=1)
BS.call
BS.put<-BS.call-stock+strike*exp(-rf*TTM)
BS.put
 #”ctrl+shft+enter” to process#

No comments:

Post a Comment