Matlab → Function → Black-Scholes Option Prices
In the next example, call and put option values are calculated using Black-Scholes formula. Remember the option parameter values are given in the command window when we are executing the program. Here we used, , and .
% Function calculating call and put
function [call, put] = CallPut(s,k,r,v,t)
d1=(log(s/k)+(r+v^2/2)*t)/(v*sqrt(t));
d2=d1-v*sqrt(t);
call=s*normcdf(d1)-k*exp(-r*t)*normcdf(d2)
put=k*exp(-r*t)*normcdf(-d2)-s*normcdf(-d1)
To run this program, we need to write function name (for example, CallPut in this example) and input values in the command window. Like,
Command Window
>> CallPut(50,52,0.1,0.35,1)
call =
8.3158
put =
5.3673