I'm quite beginning with matlab and have a question maybe simple ?
i got Black&Scholes formula to get a call option price with the following input parameters : S = stock price, K = strike , r = rate, T = time to expiration , sigma = volatility
Call option price is given by :
C(S,K,r,t,sigma) = S *N(d1) - K e^-rT *N(d2)
d1 = (1/sqrt(T))*(ln(S/K)+(r+0.5*sigma^2)*T)
d2 = d1 - sigma*sqrt(T)
I have no probleme with this function but i need to get the black scholes volatility.
I have as inputs : S, K , r , T , BlackScholesPrice
and i want to return sigma.
I tried with "syms sig; solve ("blackscholesequation"==blacksholesprice, sig);" but there's nothing to do, i always get an error
"Error using symfun>validateArgNames (line 211)
Second input must be a scalar or vector of unique symbolic variables.
Error in symfun (line 45)
y.vars = validateArgNames(inputs);
Error in sym/subsasgn (line 762)
C = symfun(B,[inds{:}]);
Error in normcdf>localnormcdf (line 100)
p(sigma==0 & x<mu) = 0;
Error in normcdf (line 46)
[varargout{1:max(1,nargout)}] = localnormcdf(uflag,x,varargin{:});
Error in BlackScholesInverse (line 3)
solve(S0*normcdf((log(S0/K)+(r+0.5*sig*sig)*T)*(1/(sig*sqrt(T))))-K*exp(-r*T)*normcdf((log(S0/K)+(r+0.5*sig*sig)*T)*(1/(sig*sqrt(T)))-sig*sqrt(T))==
prixBS,sig)"
If anybody got an idea it would be awesome. Thx all'