## IBTlocsigma (MatLab R2007b)

estimates the implied local volatility of each node in the implied binomial tree. Required by XFGIBT02.m.

Click the button to demonstrate a graph view.
Notice: This content requires Java Runtime Environment.
Java Applet and JavaScript should be allowed on your browser.

Fri, July 27 2012 by Dedy Dwi Prastyo

`[loc,lv,st,mat] = IBTlocsigma(St, prob, m, deltat)`

- Stock prices of the nodes in the implied tree, transition probabilities of the nodes in the implied tree, both generated by IBTdk or IBTbc, the highest level desired, the length of time step (by year)

- Matrix with 3 columns, containing the stock price at some node in implied binomial tree, the time to expiration and the estimated implied local volatility; matrix of estimated implied local volatility; stock prices and time to expiration

Description: r=0.03; riskless annual interest rate S=100; the underlying asset price expiration=1; time to expiration lev=3; the number of time steps deltat=expiration/lev; [S, AD, p, LV] = IBTdk(S, r, expiration, lev, []); [loc,lv,st t]=IBTlocsigma(S, p, lev, deltat)

```function[loc,lv,strike,mat]=IBTlocsigma(Stree, prob, m, deltat)
%error((cols(prob)~=rows(prob)),'IBTlocsigma: data matrix must be symmetric')
%error((deltat<=0),'IBTlocsigma: the length of time step needs to be larger than 0')
%error(((m<0) || (floor(m)~=m)),'IBTlocsigma: the number of the steps should be a natural number')
[lev,node]=size(Stree);
j=1;
s = sum(m-1:-1:1);
lv = zeros((m^2-s),m);
strike = zeros((m^2-s),1);
mat = deltat:deltat:m*deltat;
loc=zeros(1,3);
p=zeros(m+1,1);
ind = 0;
while(j<lev)
i=1;
while(i<=j)
ind = ind+1;
k=1;
pp=zeros(m+1,1);
pp(1)=(1-prob(i,j));
pp(2)=prob(i,j);
sig=sqrt(pp(1)*pp(2))*abs(log(Stree(i,j+1))-log(Stree(i+1,j+1)));
lv(ind,k) = sig;
strike(ind) =Stree(i,j);
n = [Stree(i,j) (k*deltat) sig];
loc=[loc; n];
k=2;
while(k <lev-j+1 && k< m+1 )
p(1)=pp(1)*(1-prob(i,j+k-1));
p(2:k)=pp(1:k-1).*prob(i:(i+k-2),j+k-1)+pp(2:k).*(1-prob((i+1):(i+k-1),j+k-1));
p(k+1)=prob((i+k-1), j+k-1)*pp(k);
t=log(Stree(i:(i+k),(j+k)));
mm=sum(p(1:k+1).*t);
ms=t-mm;
sig=sqrt(sum(p(1:k+1).*(ms.*ms)));
lv(ind,k) = sig;
strike(ind) =Stree(i,j);
n = [Stree(i,j) (k*deltat) sig];
loc=[loc; n];
pp=p;
k=k+1;
end
i=i+1;
end
j=j+1;
end
loc=loc(2:end,:);```