Google Ad sense



All source codes in this blog are also available in Gregory Choi's Github Source code Repository


  

Saturday, April 16, 2016

How to calculate Black-Scholes formula in R

Well, seeing is believing. Let's watch Youtube video to master what we've learn through R tutorial.




As I mentioned in the video, please use "pnorm" function to calculate the normal distribution. "dnorm" function calculates just density function suitable for drawing actual normal distribution curve.

[Code]

#Black Scholes Model

s<-100 #Stock Price
x<-105 #Exercise Price
t<-1 #Expiration Date
sigma<-0.2 #Volatility
rfree<-0.03 #Risk Free Rate

d1<-(log(s/x) + rfree * t)/(sigma*sqrt(t)) + sigma*sqrt(t)/2
d2<-d1 - sigma*sqrt(t)

c<-s*pnorm(d1)-exp(-rfree*t)*x*pnorm(d2)


No comments:

Post a Comment