# Matlab-GUI equity derivative calculator

by

### Biao (view profile)

24 May 2007 (Updated )

equity derivative calculator using matlab GUI

[call,put]=FloatingLookback(S,r,T,sigma,d,Smax,Smin)
```function [call,put]=FloatingLookback(S,r,T,sigma,d,Smax,Smin)

%Floating strike Lookback option
%S: price of stock; d: dividend rate;
%T: time to maturity; max, min: up to current the max/min stock price;

a1=(log(S/Smin)+(r-d+sigma^2/2)*T)/(sigma*sqrt(T));
a2=a1-sigma*sqrt(T);
a3=(log(S/Smin)+(-r+d+sigma^2/2)*T)/(sigma*sqrt(T));
r1=-2*(r-d-sigma^2/2)*log(S/Smin)/sigma^2;

call=S*exp(-d*T)*normcdf(a1)-S*exp(-d*T)*sigma^2/(2*(r-d))*normcdf(-a1)...
-Smin*exp(-r*T)*(normcdf(a2)-sigma^2/(2*(r-d))*exp(r1)*normcdf(-a3));

b1=(log(Smax/S)+(-r+d+sigma^2/2)*T)/(sigma*sqrt(T));
b2=b1-sigma*sqrt(T);
b3=(log(Smax/S)+(r-d-sigma^2/2)*T)/(sigma*sqrt(T));
r2=2*(r-d-sigma^2/2)*log(Smax/S)/sigma^2;

put=S*exp(-d*T)*sigma^2/(2*(r-d))*normcdf(-b2)-S*exp(-d*T)*normcdf(b2)...
+Smax*exp(-r*T)*(normcdf(b1)-sigma^2/(2*(r-d))*exp(r2)*normcdf(-b3));```