The following code provided a precise calculation of the Binomial Option Pricing Model, with a comparison to it’s special case Black Scholes Formula (contious case). Finally, I link the result we obtian from the Binomial Option Pricing Model to one of the Greeks letter delta, and analyze some trend I obtained.

Some Parameters:

1)delta_t: Time/step, length of each step but not overall options, ie, 5 years maturity, if I want to divided into 5 steps, then delta_t = 1, one year each step. 2)implied (historical) volatility: the market expected magnitude for stock price changes in the future 3)u & d: the magitude of an up jump and down jump will be calculated under the assumption of sigma 4)p&q:the porbability of up jump and down jump under risk neutral probability will also be consdiered under volatility 5)S0: Current Stock Price

option_pricing = function(Maturity_Time, delta_t, S0, Strike_Price, Int_rate,sigma, type){
  model = matrix(0, nrow=Maturity_Time+1, ncol=Maturity_Time+1);
  u = exp(sigma*sqrt(delta_t))
  d = exp(-sigma*sqrt(delta_t))
  for (i in 1:(Maturity_Time+1)){
    for(j in 1:i){
      model[i,j]=S0 * u^(j-1) * d^((i-1)-(j-1))
    }
  }
  
  #calculate S(n) and presents by a matrix. 
  #for instance, if we have T=2 for maturity, we will create a (2+1) x (2+1) matrix, the algorithm will be as follow: 
  #for i =1 ->  j = 1 -> model[1,1](the inital value) = S(0);
  #for i = 2 -> j = 1 -> model[2,1] = S(0)*d = S1(T);
  #          -> j = 2 -> model[2,2] = S(0)*u = S1(H);
  #for i = 3 -> j = 1 -> model[3,1] = S(0)*d^2 = S2(TT);
  #          -> j = 2 -> model[3,2] = S(0)*u*d = S2(TH) or S2(HT);
  #          -> j = 3 -> model[3,3] = S(0)*u^2 = S2(HH)
  #[[1]]
  #        [,1]     [,2]     [,3]
  #[1,] 110.00000   0.0000   0.0000
  #[2,]  94.67788 127.8018   0.0000
  #[3,]  81.49000 110.0000 148.4845
  
  #also note that in the lectrue we are familiar with the formula of p= (1+r-d)/(u-d) 
  #but the actual formula for p is (exp(Int_rate*delta_t)-d)/(u-d); 
  #in fact, 1+r is <= e^r and because the binomail model is in discrete caes, we used 1 + r, and the formula we should have for p should actually be
  # (exp((r-dividen))*delta_t)-d)/(u-d) - but we have dividen = 0 and delta_t = 1 in our lecture. That is why it becomes 1+r, of course this will also change after we considered volatility
  
  u <- exp(sigma*sqrt(delta_t))
  d <- exp(-sigma*sqrt(delta_t)) 
  p <- (exp(Int_rate*delta_t)-d)/(u-d);
  q <- 1-p;
  option = matrix (0,nrow(model),ncol(model))
  if(type == "put"){
    option[nrow(model),]=pmax(Strike_Price- model[nrow(model),],0)
  }
  else{
    option[nrow(model),]=pmax(model[nrow(model),]- Strike_Price,0)
  }
  for (i in (Maturity_Time):1){
    for (j in 1:i){
      option[i,j]=(q*option[i+1,j]+p*option[i+1,j+1])/exp(Int_rate*delta_t) # we have 1/(1+r)
    }
  }
  #
#  [[2]]
#          [,1]     [,2]     [,3]
#  [1,] 28.66353  0.00000  0.00000
#  [2,]  7.34573 37.31802  0.00000
#  [3,]  0.00000 10.00000 48.4844


 
  price = option[1,1]
  list<-list(model, option, price)
  return(list)

}

option_pricing(Maturity_Time = 5,delta_t = 1,S0=110,Strike_Price = 100,Int_rate = 0.1,sigma = 0.15,type='call')
## [[1]]
##           [,1]      [,2]      [,3]     [,4]     [,5]   [,6]
## [1,] 110.00000   0.00000   0.00000   0.0000   0.0000   0.00
## [2,]  94.67788 127.80177   0.00000   0.0000   0.0000   0.00
## [3,]  81.49000 110.00000 148.48447   0.0000   0.0000   0.00
## [4,]  70.13910  94.67788 127.80177 172.5143   0.0000   0.00
## [5,]  60.36928  81.49000 110.00000 148.4845 200.4331   0.00
## [6,]  51.96032  70.13910  94.67788 127.8018 172.5143 232.87
## 
## [[2]]
##          [,1]     [,2]     [,3]     [,4]      [,5]   [,6]
## [1,] 49.58773  0.00000  0.00000  0.00000   0.00000   0.00
## [2,] 28.61885 60.87205  0.00000  0.00000   0.00000   0.00
## [3,] 11.01989 36.40558 74.42892  0.00000   0.00000   0.00
## [4,]  0.00000 15.00176 46.08298 90.64127   0.00000   0.00
## [5,]  0.00000  0.00000 20.42243 58.00073 109.94933   0.00
## [6,]  0.00000  0.00000  0.00000 27.80177  72.51434 132.87
## 
## [[3]]
## [1] 49.58773

Let us now compare it to the Balck Scholes Formula

BlackScholes <- function(S, K, r, T, sig, type){
  
  if(type=="C"){
    d1 <- (log(S/K) + (r + sig^2/2)*T) / (sig*sqrt(T))
    d2 <- d1 - sig*sqrt(T)
    
    value <- S*pnorm(d1) - K*exp(-r*T)*pnorm(d2)
    return(value)}
  
  if(type=="P"){
    d1 <- (log(S/K) + (r + sig^2/2)*T) / (sig*sqrt(T))
    d2 <- d1 - sig*sqrt(T)
    
    value <-  (K*exp(-r*T)*pnorm(-d2) - S*pnorm(-d1))
    return(value)}
}
call <- BlackScholes(110,100,0.1,5,0.15,"C")
call
## [1] 49.75904

We can see the result is pretty similar, indeed Balck Scholes Formula is the continous case of Binomal Model, the result should be close.

Now I link the Binomial_Option_Price to the Greeks Delta.Delta is the difference between the stock price divide difference between the option price. By calculating the delta, we can obtian the probability of ‘in the money’

in the follwoing code, I fix all the other value (ie, the u&d, Maturity Time, Strike Price, Intrest Rate, and sigma, delta_t) instead of S0. And I set the range of S0 to 60-500, I would like to see how the Delta will change along with the increase of S0.

list_S0 <- c()
list_K <- c()
list_delta <- c()
list_V0 <- c()
T <- 5 #change of T will be 1 
sigma<-0.15
delta_t <- 1/5 
u <- exp(sigma*sqrt(delta_t))
d <- exp(-sigma*sqrt(delta_t))
S0 <- 60
K <- 100
r <- 0.1
repeat{
  model = matrix(0, 6, 6);
  for (i in 1:(6)){
    for(j in 1:i){
      model[i,j]=S0 * u^(j-1) * d^((i-1)-(j-1))
    }
  }
  
  option = matrix (0,nrow(model),ncol(model))
  option[nrow(model),]=pmax(model[6,]-K ,0)
  
  p <- (exp(r*delta_t)-d)/(u-d);
  q <- 1-p;
  for (i in 5:1){
    for (j in 1:i){
      option[i,j]=(q*option[i+1,j]+p*option[i+1,j+1])/exp(r*delta_t)
    }
  }
  delta = option[1,1]/model[1,1]
  list_delta[[S0]]=delta
  list_S0[[S0]]=S0
  list_K[[S0]]=K
  list_V0[[S0]]=option[1,1]
  S0 = S0+1
  if (S0 == 500){
    break
    
  }
  
}




par(mfrow = c(1, 2))
list_delta
##   [1]           NA           NA           NA           NA           NA
##   [6]           NA           NA           NA           NA           NA
##  [11]           NA           NA           NA           NA           NA
##  [16]           NA           NA           NA           NA           NA
##  [21]           NA           NA           NA           NA           NA
##  [26]           NA           NA           NA           NA           NA
##  [31]           NA           NA           NA           NA           NA
##  [36]           NA           NA           NA           NA           NA
##  [41]           NA           NA           NA           NA           NA
##  [46]           NA           NA           NA           NA           NA
##  [51]           NA           NA           NA           NA           NA
##  [56]           NA           NA           NA           NA 0.0000000000
##  [61] 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000
##  [66] 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000
##  [71] 0.0000000000 0.0008899673 0.0026491701 0.0043608270 0.0060268397
##  [76] 0.0076490099 0.0092290459 0.0107685681 0.0122691151 0.0137321483
##  [81] 0.0151590574 0.0174633996 0.0227485215 0.0279078073 0.0329456980
##  [86] 0.0378664286 0.0426740388 0.0473723853 0.0519651508 0.0564558550
##  [91] 0.0608478623 0.0651443912 0.0693485217 0.0751789666 0.0826667804
##  [96] 0.0899985980 0.0971792441 0.1042133465 0.1111053457 0.1178595050
## [101] 0.1244799185 0.1309705200 0.1373350904 0.1435772653 0.1497005415
## [106] 0.1557082842 0.1617000010 0.1690317159 0.1762289039 0.1832952340
## [111] 0.1902342429 0.1970493408 0.2037438175 0.2103208473 0.2167834940
## [116] 0.2231347157 0.2293773695 0.2355142157 0.2415479215 0.2474810656
## [121] 0.2533161412 0.2590555598 0.2649444107 0.2708378673 0.2766370286
## [126] 0.2823441398 0.2879613752 0.2934908413 0.2989345792 0.3042945673
## [131] 0.3095727236 0.3147709077 0.3198909237 0.3249345216 0.3299033994
## [136] 0.3347992056 0.3396235401 0.3443779567 0.3490639645 0.3536875585
## [141] 0.3582713347 0.3627905507 0.3672465608 0.3716406819 0.3759741945
## [146] 0.3802483438 0.3844643415 0.3886233662 0.3927265651 0.3967750546
## [151] 0.4007699218 0.4047122250 0.4086029947 0.4124432350 0.4162339238
## [156] 0.4199760141 0.4236704344 0.4273180899 0.4309198629 0.4344766137
## [161] 0.4379891813 0.4414583839 0.4448850196 0.4482698671 0.4516136860
## [166] 0.4549172181 0.4581811868 0.4614062988 0.4645932438 0.4677426953
## [171] 0.4708553111 0.4739317337 0.4769725907 0.4799784954 0.4829500468
## [176] 0.4858878307 0.4887924192 0.4916643719 0.4945042357 0.4973125455
## [181] 0.5000898243 0.5028365835 0.5055533235 0.5082405337 0.5108986930
## [186] 0.5135282699 0.5161297230 0.5187035010 0.5212500434 0.5237697800
## [191] 0.5262631319 0.5287305114 0.5311723223 0.5335889598 0.5359808113
## [196] 0.5383482561 0.5406916660 0.5430114050 0.5453078301 0.5475812910
## [201] 0.5498321303 0.5520606841 0.5542672818 0.5564522461 0.5586158936
## [206] 0.5607585349 0.5628804744 0.5649820106 0.5670634363 0.5691250390
## [211] 0.5711671005 0.5731898972 0.5751937005 0.5771787766 0.5791453870
## [216] 0.5810937879 0.5830242313 0.5849369642 0.5868322292 0.5887102645
## [221] 0.5905713041 0.5924155775 0.5942433103 0.5960547241 0.5978500364
## [226] 0.5996294610 0.6013932079 0.6031414833 0.6048744899 0.6065924269
## [231] 0.6082954900 0.6099838715 0.6116577605 0.6133173427 0.6149628008
## [236] 0.6165943144 0.6182120599 0.6198162109 0.6214069381 0.6229844092
## [241] 0.6245487892 0.6261002405 0.6276389226 0.6291649926 0.6306786049
## [246] 0.6321799114 0.6336690615 0.6351462024 0.6366114787 0.6380650328
## [251] 0.6395070048 0.6409375325 0.6423567518 0.6437647960 0.6451617968
## [256] 0.6465478836 0.6479231836 0.6492878225 0.6506419235 0.6519856084
## [261] 0.6533189969 0.6546422069 0.6559553544 0.6572585538 0.6585519177
## [266] 0.6598355571 0.6611095813 0.6623740977 0.6636292126 0.6648750304
## [271] 0.6661116539 0.6673391845 0.6685577223 0.6697673657 0.6709682116
## [276] 0.6721603558 0.6733438924 0.6745189144 0.6756855132 0.6768437793
## [281] 0.6779938014 0.6791356674 0.6802694636 0.6813952753 0.6825131867
## [286] 0.6836232804 0.6847256383 0.6858203410 0.6869074678 0.6879870972
## [291] 0.6890593065 0.6901241719 0.6911817686 0.6922321707 0.6932754515
## [296] 0.6943116831 0.6953409367 0.6963632825 0.6973787900 0.6983875273
## [301] 0.6993895621 0.7003849609 0.7013737894 0.7023561125 0.7033319941
## [306] 0.7043014974 0.7052646847 0.7062216175 0.7071723566 0.7081169619
## [311] 0.7090554926 0.7099880070 0.7109145629 0.7118352172 0.7127500260
## [316] 0.7136590449 0.7145623287 0.7154599314 0.7163519066 0.7172383069
## [321] 0.7181191844 0.7189945907 0.7198645765 0.7207291920 0.7215884868
## [326] 0.7224425098 0.7232913095 0.7241349335 0.7249734292 0.7258068430
## [331] 0.7266352211 0.7274586090 0.7282770516 0.7290905934 0.7298992782
## [336] 0.7307031494 0.7315022498 0.7322966219 0.7330863074 0.7338713476
## [341] 0.7346517836 0.7354276555 0.7361990035 0.7369658669 0.7377282846
## [346] 0.7384862954 0.7392399372 0.7399892477 0.7407342642 0.7414750234
## [351] 0.7422115618 0.7429439153 0.7436721195 0.7443962096 0.7451162203
## [356] 0.7458321859 0.7465441406 0.7472521179 0.7479561510 0.7486562728
## [361] 0.7493525158 0.7500449121 0.7507334937 0.7514182917 0.7520993375
## [366] 0.7527766617 0.7534502948 0.7541202668 0.7547866076 0.7554493465
## [371] 0.7561085127 0.7567641349 0.7574162418 0.7580648615 0.7587100219
## [376] 0.7593517505 0.7599900748 0.7606250217 0.7612566179 0.7618848900
## [381] 0.7625098640 0.7631315660 0.7637500214 0.7643652557 0.7649772940
## [386] 0.7655861611 0.7661918816 0.7667944799 0.7673939799 0.7679904056
## [391] 0.7685837806 0.7691741281 0.7697614712 0.7703458330 0.7709272359
## [396] 0.7715057025 0.7720812549 0.7726539151 0.7732237048 0.7737906455
## [401] 0.7743547586 0.7749160652 0.7754745861 0.7760303421 0.7765833536
## [406] 0.7771336409 0.7776812241 0.7782261230 0.7787683574 0.7793079468
## [411] 0.7798449105 0.7803792675 0.7809110368 0.7814402372 0.7819668872
## [416] 0.7824910053 0.7830126096 0.7835317182 0.7840483489 0.7845625195
## [421] 0.7850742475 0.7855835502 0.7860904449 0.7865949486 0.7870970781
## [426] 0.7875968502 0.7880942815 0.7885893883 0.7890821869 0.7895726935
## [431] 0.7900609239 0.7905468940 0.7910306194 0.7915121157 0.7919913982
## [436] 0.7924684821 0.7929433826 0.7934161146 0.7938866929 0.7943551323
## [441] 0.7948214472 0.7952856520 0.7957477612 0.7962077887 0.7966657488
## [446] 0.7971216551 0.7975755217 0.7980273620 0.7984771897 0.7989250182
## [451] 0.7993708607 0.7998147305 0.8002566406 0.8006966040 0.8011346334
## [456] 0.8015707417 0.8020049413 0.8024372450 0.8028676649 0.8032962135
## [461] 0.8037229028 0.8041477450 0.8045707520 0.8049919358 0.8054113079
## [466] 0.8058288802 0.8062446642 0.8066586714 0.8070709130 0.8074814004
## [471] 0.8078901448 0.8082971572 0.8087024486 0.8091060300 0.8095079120
## [476] 0.8099081055 0.8103066210 0.8107034690 0.8110986601 0.8114922046
## [481] 0.8118841127 0.8122743946 0.8126630604 0.8130501202 0.8134355839
## [486] 0.8138194613 0.8142017622 0.8145824963 0.8149616732 0.8153393024
## [491] 0.8157153935 0.8160899557 0.8164629984 0.8168345308 0.8172045620
## [496] 0.8175731012 0.8179401573 0.8183057394 0.8186698561
plot(list_S0,list_delta)
plot(list_S0,list_V0)

From the first plot, we can see when S0 increase, delta will also increase, meaning that the probability of ‘in the money’ is getting bigger. However, it is definitely not a lienar trend. It is also true that when S0 increase, the price of option (V0) is also getting bigger, and this is linear! Because it is calculated by subtraction max(St-K,0).

list_S0 <- c()
list_K <- c()
list_delta <- c()
list_V0 <- c()
T <- 5 #change of T will be 1 
sigma<-0.15
delta_t <- 1/5 
u <- exp(sigma*sqrt(delta_t))
d <- exp(-sigma*sqrt(delta_t))
S0 <- 110
K <- 60
r <- 0.1
repeat{
  model = matrix(0, 6, 6);
  for (i in 1:(6)){
    for(j in 1:i){
      model[i,j]=S0 * u^(j-1) * d^((i-1)-(j-1))
    }
  }
  
  option = matrix (0,nrow(model),ncol(model))
  option[nrow(model),]=pmax(model[6,]-K ,0)
  
  p <- (exp(r*delta_t)-d)/(u-d);
  q <- 1-p;
  for (i in 5:1){
    for (j in 1:i){
      option[i,j]=(q*option[i+1,j]+p*option[i+1,j+1])/exp(r*delta_t)
    }
  }
  delta = (option[1,1]/model[1,1])
  list_delta[[K]]=delta
  list_S0[[K]]=S0
  list_K[[K]]=K
  list_V0[[K]]=option[1,1]
  K = K+1
  if (K == 250){
    break
    
  }
  
}

par(mfrow = c(1, 2))
plot(list_K,list_delta)
plot(list_K,list_V0)

#estimated delta% of chance that the option will expire in the money.

Now let’s try to fix other values, instead of the strike price, and set the range of strike price from 60-250. Compare it to the change of Delta From the plot, again it shows a non linear relationship between the strike price and delta, as the Delta reach some points, the probability of getting in the money actually reachs to 0.