Serving the Quantitative Finance Community

 
MAYbe
Topic Author
Posts: 30
Joined: July 8th, 2016, 2:37 pm

Understanding what is being solved for? (Python -code)

April 9th, 2017, 10:40 pm

So i got a python code from a friend that solves for equation (23) and (29) from  Bunch and Johnson (2000) [attached],
From the paper we have equation (22):   $${\textstyle{{{S_c}} \over X}} = {e^{ - (r + (1/2){\sigma ^2})\tau  - g\sigma \sqrt \tau  }}$$
where (23):  $$g =  \pm \sqrt {2\log {{{\sigma ^2}} \over {{{2r} \over {\sqrt a }}x\log x{e^{ - a{{(r + (1/2){\sigma ^2})}^2}\tau /(2{\sigma ^2})}}}}} $$ 
here  $$a = 1 - {A \over {1 + {{{{(1 + \gamma )}^2}} \over 4}{\gamma ^2}\tau }},A = {1 \over 2}{\left( {{\gamma  \over {1 + \gamma }}} \right)^2}$$ and $$x = {X \over {{S_c}}},\gamma  = {{2r} \over {{\sigma ^2}}}$$
NOW, to the question, Here is the Python code:


def func_23(gamma,S,K,r,t,vol,tau):
  alpha = 1.0 - ( .5 * gamma * gamma / (1.0 + gamma)**2 ) / ( 1.0 + (1.0 + gamma)**2 * vol * vol * (tau - t) / 4.0 )
  val1 = (r+.5*vol*vol)*(tau-t)
  val2 = exp(-alpha*(tau-t)*(r-.5*vol*vol)*(r-.5*vol*vol)/(2*vol*vol))
  val3 = vol*vol*sqrt(alpha)/r/2.0
  func = lambda g: exp(g*g/2) - val3 / (val1+g*vol*sqrt(tau-t)) / exp(val1+g*vol*sqrt(tau-t)) / val2
  g = fsolve(func,1.5)
  exer_price = K * exp( -(r + .5 * vol * vol)*(tau-t) - g * vol * sqrt(tau-t))
HOW or I CANT see how 
g: exp(g*g/2) - val3 / (val1+g*vol*sqrt(tau-t)) / exp(val1+g*vol*sqrt(tau-t)) / val2
Represents equation (23)?

note: where exer_price is Sc, vol is sigma, a is alpha, K is X, (tau-t) is $\tau$.
Attachments
untitled.pdf
(152.8 KiB) Downloaded 171 times