- Joined
- 4/15/11
- Messages
- 1
- Points
- 11
Hi all,
for my project at uni I wanted to implement a modified binomial approach to price barrier options in Matlab.
In the first step I am approximating the price process by a step function Z with jumps at random times r_n. Z(t) jumps if and only if the price process Y changes by delta.
For a given accuracy delta we can define a step function according to:
r_0 = 0
r_n = inf{t \in [0,T] | t > r_(n-1), |Y(t) - Y(r_(n-1))| >delta}
Z(t) = \sum{n=0}{\infty} Y(r_n)*1_{r_n, r_(n+1)}(t)
I am struggling with the matlab implementation. I started learning Matlab 2 days ago and still are not really familiar with it.
I have problems to implement the stopping times. I want to be able to get the values r_n since i need to calculations with them at a later point.
Could you help me here?
Thank you!
I modelled the price process like this:
function X = binomialbarrier(delta,rate,vola,barrier,T,spot,K)
%Binomial Tree
N=90
t = (0:1:N)'/N; % t is the column vector [0 1/N 2/N ... 1]
W = [0; cumsum(randn(N,1))]/sqrt(N); % S is running sum of N(0,1/N) variables
t = t*T;
W = W*sqrt(T);
Y = log(spot)+(rate-(vola^2)/2)*t + vola * W; %geometric brownian motion
for my project at uni I wanted to implement a modified binomial approach to price barrier options in Matlab.
In the first step I am approximating the price process by a step function Z with jumps at random times r_n. Z(t) jumps if and only if the price process Y changes by delta.
For a given accuracy delta we can define a step function according to:
r_0 = 0
r_n = inf{t \in [0,T] | t > r_(n-1), |Y(t) - Y(r_(n-1))| >delta}
Z(t) = \sum{n=0}{\infty} Y(r_n)*1_{r_n, r_(n+1)}(t)
I am struggling with the matlab implementation. I started learning Matlab 2 days ago and still are not really familiar with it.
I have problems to implement the stopping times. I want to be able to get the values r_n since i need to calculations with them at a later point.
Could you help me here?
Thank you!
I modelled the price process like this:
function X = binomialbarrier(delta,rate,vola,barrier,T,spot,K)
%Binomial Tree
N=90
t = (0:1:N)'/N; % t is the column vector [0 1/N 2/N ... 1]
W = [0; cumsum(randn(N,1))]/sqrt(N); % S is running sum of N(0,1/N) variables
t = t*T;
W = W*sqrt(T);
Y = log(spot)+(rate-(vola^2)/2)*t + vola * W; %geometric brownian motion