-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions_pricing_sample.php
More file actions
57 lines (43 loc) · 1.23 KB
/
options_pricing_sample.php
File metadata and controls
57 lines (43 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/local/bin/php
<?php
/********************************************************************
*
* options_pricing_sample.php
*
* Copyright 2017 Shu G. & qa-apps.com
*
* Exotic options pricing library
* https://github.com/xscheme/exotic_options
*
* Reference: Kerry Back, A Course in Derivative Securities:
* Introduction to Theory and Computation, Springer, 2010.
* MathPHP: https://github.com/markrogoyski/math-php
*********************************************************************/
include('options.inc.php');
$S = 50;
$K = 55;
$r = 0.05;
$sigma = 0.2;
$q = 0.02;
$T = 1;
echo <<<PARAMETERS
=======================
Sample Input Parameters
=======================
\$S (initial stock price): $S
\$K (the strike price): $K
\$r (risk-free rate): $r
\$sigma (volatility): $sigma
\$q (dividend yield): $q
\$T (time to maturity): $T
PARAMETERS;
$option_value = black_scholes_call ($S, $K, $r, $sigma, $q, $T);
$option_value = sprintf('%.6f', $option_value);
echo <<<PARAMETERS
====================
Sample Function Call
====================
\$option_value = black_scholes_call(\$S, \$K, \$r, \$sigma, \$q, \$T);
\$option_value: $option_value
PARAMETERS;
?>