Matlab Black Scholes公式如何从B&S价格中得到波动。

时间:2021-01-19 12:34:03

I'm quite beginning with matlab and have a question maybe simple ?

我从matlab开始,有个简单的问题?

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

我得到了Black&Scholes公式,得到一个看涨期权价格,其输入参数为:S =股价,K = strike, r = rate, T =时间到期日,sigma =波动率。

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.

我对这个函数没有问题,但是我需要得到black scholes的波动性。

I have as inputs : S, K , r , T , BlackScholesPrice and i want to return sigma.

我有输入:S K r T, BlackScholesPrice我想返回sigma。

I tried with "syms sig; solve ("blackscholesequation"==blacksholesprice, sig);" but there's nothing to do, i always get an error

我尝试用syms sig;解(“blackscholesequation”==blacksholesprice, sig);“但没有什么可做的,我总是会出错。

"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'

如果有人知道,那就太棒了。谢谢所有的

1 个解决方案

#1


0  

You are trying to find implied volatility. For that you can use blsimpv. It would be easier to use this function, just that you need to give the inputs according.

你试图找到隐含波动率。你可以使用blsimpv。使用这个函数会更容易,只是需要根据需要给出输入。

#1


0  

You are trying to find implied volatility. For that you can use blsimpv. It would be easier to use this function, just that you need to give the inputs according.

你试图找到隐含波动率。你可以使用blsimpv。使用这个函数会更容易,只是需要根据需要给出输入。