org-howto/option/blackscholes/index.org

3.5 KiB
Raw Permalink Blame History

black-scholes example

#

#

#

Introduction

This is intended to be an interactive Black-Scholes option-pricing demonstration. Warning: Work in progress

  • .org source for this page is here: index.org

Option pricing

The Black-Scholes formula for European call options is: $$ C(s,t) = N(d_{1})S = N(d_{2})Ke^{-r\tau} $$ where $N(x)$ is the cumulative normal distribution function: $$ N(x) = \frac{1}{\sqrt{2\pi}}\int_{-\infty}^{x}{e^{-\frac{x^2}{2}} dx} $$ We also have $N'(x)$ is the normal probability density function: $$ N'(x) = \frac{1}{\sqrt{2\pi}}e^{-\frac{x^2}{2}} $$ $$ d_{1} = \frac{1}{\sigma\sqrt{\tau}} \left[\ln{\left(\frac{S}{K}\right)}+\left(r+\frac{\sigma^2}{2}\right)\tau\right] $$ and $$ d_{2} = d_{1} - \sigma\sqrt{\tau} $$

We also have greeks: $$ delta: \frac{\partial C}{\partial S} = N(d_{1}) $$ $$ gamma: \frac{N'(d1)}{S\sigma\sqrt{\tau}} $$

Demo

The div element #frame will appear below this line:

Prerequisites

  1. d3 example #1 prerequisites (D3, webserver)
  2. jquery installed in $HTTP_ROOT/ext/jquery:

    ls -l $HOME/proj/public_html/org-howto/ext/jquery

    total 88 -rw-rr 1 roland roland 87533 Oct 18 1991 jquery-3.7.1.min.js

Procedure

Cumulative normal distribution

We use the ubiquitous polynomial approximation. Write normal.js

Black-Scholes call

Write blackscholes.js

Insert html fragment to invoke our interactive javascript code

This also follows the same model we used in examples #3, #4, #5.

 #+begin_html
 <div id="frame"></div>
 <script type="text/javascript">
   window.onload = function() { ex.start(this); }
 </script>
 #+end_html