No BSD License  

Highlights from
Matlab-GUI equity derivative calculator

image thumbnail

Matlab-GUI equity derivative calculator

by

 

24 May 2007 (Updated )

equity derivative calculator using matlab GUI

OptionValue=ChooserOption(S,kc,kp,r,Tc,Tp,sigma,d,t)
function OptionValue=ChooserOption(S,kc,kp,r,Tc,Tp,sigma,d,t)

%S: price of stock; d: dividend rate;
%T: time to maturity; t: choose time;
%k: strike of call or put, where the call and put have different strike and
%time to maturity.

if kc==kp & Tc==Tp
    [tempc,tempp]=blsprice(S,kc*exp(-(r-d)*(Tc-t)),r,t,sigma,d);
    OptionValue=blsprice(S,kc,r,Tc,sigma,d)+exp(-d*(Tc-t))*tempp;
else
    %find the stock price letting call=put
    maxiter = 500;
    tol = 1e-6;
    o = optimset('MaxIter', maxiter, 'TolFun', tol);
    [Sstar, fval, exitFlag] = fzero(@corp1, S, o,kc,kp,r,Tc,Tp,sigma,d,t);
    part1=exp(-r*Tp)*kp*cbnd(-normd2(S,Sstar,r,t,sigma,d),-normd2(S,kp,r,Tp,sigma,d),sqrt(t/Tp))...
        -exp(-d*Tp)*S*cbnd(-normd1(S,Sstar,r,t,sigma,d),-normd1(S,kp,r,Tp,sigma,d),sqrt(t/Tp));
    part2=-exp(-r*Tc)*kc*cbnd(normd2(S,Sstar,r,t,sigma,d),normd2(S,kc,r,Tc,sigma,d),sqrt(t/Tc))...
        +exp(-d*Tc)*S*cbnd(normd1(S,Sstar,r,t,sigma,d),normd1(S,kc,r,Tc,sigma,d),sqrt(t/Tc));
    OptionValue=part1+part2;
end


function [d1]=normd1(S,k,r,t,sigma,d)
d1=(log(S/k)+(r-d+sigma^2/2)*t)/(sigma*sqrt(t));

function [d2]=normd2(S,k,r,t,sigma,d)
d2=(log(S/k)+(r-d-sigma^2/2)*t)/(sigma*sqrt(t));

function cd=corp1(x,kc,kp,r,Tc,Tp,sigma,d,t)
[tempcall,tempput]=blsprice(x,kp,r,Tp-t,sigma,d);
cd=blsprice(x,kc,r,Tc-t,sigma,d)-tempput;

Contact us