function [call,put,calldif,putdif]=bs(S,r,T,sigma,K,q) % S is current stock price
% r is annualized risk free rate
% T is time to expiration (in years)
% sigma is annualized stock return standard deviation/volatility
% K is strike price
% q is annualized dividend rate
temp1=(log(S/K)+(r-q+sigma^2/2)*T)/(sigma*T^0.5); temp2=temp1-sigma*T^0.5; call=S*exp(-q*T)*normcdf(temp1)-K*exp(-r*T)*normcdf(temp2); put=-S*exp(-q*T)*normcdf(-temp1)+K*exp(-r*T)*normcdf(-temp2); [a,b]=blsprice(S,K,r,T,sigma,q); [calldif,putdif]=[call,put]-[a,b] end
MATLAB: I can’t get the output? What’s wrong with line 13
output
Best Answer