I have this function
BSprice[S_, K_, r_, T_, v_, PutCall_] :=
Module[{d, bscall},
bscall = 0.0;
d = (Log[S/K] + T*(r + 0.5*v^2))/(v*Sqrt[T]);
bscall = S*Gauss[d] - Exp[-r*T]*K*Gauss[d - v*Sqrt[T]];
If[PutCall == "Call",
Return[bscall],
Return[bscall - S + K*Exp[-r*T]];
];
];
and when I explicitly put in the parameter values, I get
BSprice[319.0, 355, 0.02, 35/365, 0.1584, "Call"]
0.0952009
But when I try to do substitutions, it's another story...I get
BSprice[x, k1, r, T, \[Sigma]1, "Call"] /. {x -> 319.0, k1 -> 355,
r -> 0.02, T -> 35/365, \[Sigma]1 -> 0.1584}
-35.3198 Null
Why does this happen? What am I doing wrong? Thanks for assistance...
The other functions needed are:
Gauss[x_] := NormSDist[x];
NormSDist[x_] :=
Module[{t, b1, b2, b3, b4, b5, p, c},
t = 0;
b1 = 0.31938153;
b2 = -0.356563782;
b3 = 1.781477937;
b4 = -1.821255978;
b5 = 1.330274429;
p = 0.2316419;
c = 0.39894228;
If[x >= 0,
t = 1.0/(1.0 + p*x);
Return[(1.0 -
c*Exp[-x*x/2.0]*t*(t*(t*(t*(t*b5 + b4) + b3) + b2) + b1))],
t = 1.0/(1.0 - p*x);
Return[(c*Exp[-x*x/2.0]*
t*(t*(t*(t*(t*b5 + b4) + b3) + b2) + b1))]];
];