Hello guys, I need help with this. When I run it, I get a blank page. Please Me out.
<?php
//The Main Program
$call_put_flag="c";
$S=50;
$X=52;
$T=0.5;
$r=0.05;
$v=0.15;
BlackScholes ($call_put_flag, $S, $X, $T, $r, $v);
//echo $call_put_flag, $S, $X, $T, $r, $v;
//Commulative function
function CND ($x) {
$Pi = 3.141592653589793238;
$a1 = 0.319381530;
$a2 = -0.356563782;
$a3 = 1.781477937;
$a4 = -1.821255978;
$a5 = 1.330274429;
$L = abs($x);
$k = 1 / ( 1 + 0.2316419 * $L);
$p = 1 - 1 / pow(2 * $Pi, 0.5) * exp( -pow($L, 2) / 2 ) * ($a1 * $k + $a2 * pow($k, 2)+ $a3 * pow($k, 3) + $a4 * pow($k, 4) + $a5 * pow($k, 5) );
if ($x >= 0) {
print $p;
} else {
print 1-$p;
}
}
//BlackScholes calculation
function BlackScholes ($call_put_flag, $S, $X, $T, $r, $v)
{
$d1 = ( log($S / $X) + ($r + pow($v, 2) / 2) * $T ) / ( $v * pow($T, 0.5) );
$d2 = $d1 - $v * pow($T, 0.5);
if ($call_put_flag == 'c') {
print $S * CND($d1) - $X * exp( -$r * $T ) * CND($d2); //Call Option
} else {
print $X * exp( -$r * $T ) * CND(-$d2) - $S * CND(-$d1); //Put Option
}
?>