Black-Scholes Model is one of the most poplar mathematical method in financial market to compute derivatives investment instrument.
Here are the assumptions,
1. The stock price follows the process developed with mu (expectation)and sigma (standard deviation) constant.
2. The short selling of securities with full use of proceeds is permitted.
3. There are no transactions costs or taxes. All securities are perfectly divisible.
4. There are no dividends during the life of the derivative.
5. There are no riskless arbitrage opportunities.
6. Security trading is continuous.
7. The risk-free rate of interest, r, is constant and the same for all maturities.
BS Formula:

C--------call option
P---------put option
N(d1)------delta
N(d2)------probability of option execution
If I get the real data, I can calculate sigma. It is reversion of BS equation to calculate implied volatility(sigma)
A practice of this method shows here.
Use Bisection and Newton method to find out the root. Calculate the implied volatility.
Pseudo-code in R
###Please do not copy the code#####
#Bisection
clclt_vl_c<-function(x,k,c,r,s0,exprtn) #define a function to compare the actual call option price and option price calculated by given volatility
{
d1<-((log(s0/k))+(r+(x^2)/2)*exprtn)/(x*sqrt(exprtn)) #calculate d1
d2<-((log(s0/k))+(r-(x^2)/2)*exprtn)/(x*sqrt(exprtn)) #calculate d2
c_cmp<-s0*pnorm(d1)-k*exp(-r*exprtn)*pnorm(d2)-c #compare the two values
return(c_cmp) #return the comparison
}
impvol1<-vector() #create a vector for volatilities of AMZN
for(i in 1:7) #calculate the volatility at the money for AMZN call option
{
k<-n+5*(i-1) #the boundary of at the money is from the strike price 345
c<-(data[(x+i),3]+data1[(x+i),4])/2 #average the bid and the ask price
r<-0.0006 #risk-free interest rate
s0<-data1[1,2] #initial stock price s0 of AMZN
exprtn<-dm/365 #expiration
a<-0
b<-1 #set the range for bisection
while(b-a>0.000001) #implement the bisection method to calculate the volatility
{
x<-(a+b)/2 #midpoint between a and b
if(clclt_vl_c(a,k,c,r,s0,exprtn)*clclt_vl_c(x,k,c,r,s0,exprtn)<0) b<-x #find where the root is
else a<-x
}
vol<-(a+b)/2
impvol1[i]<-vol
}
#Newton
nwtn<-function(f,x0,tol) #create a function to implement Newton method to find root
{
d<-0.5 #initialize the difference between x0 and x1
x1<-x0
dx<-1e-10 #delta x(increment of x)
while(d>tol)
{
x0<-x1
df.dx<-(f(x0+dx)-f(x0))/dx #calculate the derivative
x1<-x0-f(x0)/df.dx
d<-abs(x1-x0) #calculate the difference between x0 and x1
}
return(x1) #output the result
}
impvol1<-vector() #create a vector for volatilities
clclt_vl_c<-function(x) #create a function of Black-Scholes formula for call optipon
{
d1<-((log(s0/k))+(r+(x^2)/2)*exprtn)/(x*sqrt(exprtn))
d2<-((log(s0/k))+(r-(x^2)/2)*exprtn)/(x*sqrt(exprtn))
c_cmp<-s0*pnorm(d1)-k*exp(-r*exprtn)*pnorm(d2)-c
return(c_cmp)
}
for(i in 1:7)
{
k<-345+5*(i-1)
c<-(data1[(33+i),3]+data1[(33+i),4])/2
r<-0.0006
s0<-data1[1,2]
exprtn<-39/365
tol<-0.000001
impvol1[i]<-nwtn(clclt_vl_c,0.2,tol) #implement Newton method to calculate the volatility
}
clclt_vl_p<-function(x) #create a function of Black-Scholes formula for put optipon
{
d1<-((log(s0/k))+(r+(x^2)/2)*exprtn)/(x*sqrt(exprtn))
d2<-((log(s0/k))+(r-(x^2)/2)*exprtn)/(x*sqrt(exprtn))
p_cmp<-k*exp(-r*exprtn)*pnorm(-d2)-s0*pnorm(-d1)-p
return(p_cmp)
}0
没有评论:
发表评论