Finite Difference method for American put option

10 Ansichten (letzte 30 Tage)
Julia
Julia am 19 Apr. 2011
I have the code for finite difference method for European put option and I need to make adjustments to this code so that it calculates the price of an American option instead of a European one. I did finite difference method in Excel about a year ago but I'm new to Matlab and haven't got a clue. I would really appreciate it if someone could tell me where in the code I should make the adjustments and what these adjustments are.
Here's the code:
function price = EuPutExpl(S0,K,r,T,sigma,Smax,dS,dt)
M = round(Smax/dS);
dS = Smax/M;
N = round(T/dt);
dt = T/N;
matval = zeros(M+1,N+1);
vetS = linspace(0,Smax,M+1);
veti = 0:M;
vetj = 0:N;
matval(:,N+1) = max(K-vetS,0);
matval(1,:) = K*exp(-r*dt*(N-vetj));
matval(M+1,:) = 0;
a = 0.5*dt*(sigma^2*veti - r).*veti;
b = 1 - dt*(sigma^2*veti.^2 + r);
c = 0.5*dt*(sigma^2*veti + r).*veti;
for j=N:-1:1
for i=2:M
matval(i,j) = a(i)*matval(i-1,j+1) + b(i)*matval(i,j+1)+c(i)*matval(i+1,j+1);
end
end
price = interp1(vetS, matval(:,1),S0);
  1 Kommentar
Walter Roberson
Walter Roberson am 19 Apr. 2011
It would probably help to post a link that explains the difference between European and American put options.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Greg
Greg am 27 Apr. 2011
For a beginner, this is quite impressive code!
I suppose for an American Put, you will just need to compute whether the put value that you compute in each loop (i.e. matval(i,j)) is the maximum value in it's row (i.e. for a given strike level). If so, set the current value equal to the maximum of that row. Otherwise, leave as is.
Good luck, and please correct me if I've made any schoolboy errors!
Greg
  1 Kommentar
Julia
Julia am 28 Apr. 2011
I was actually able to figure it out on my own. But thanks anyway.
By the way, I did not write the code above, I took it from the book.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Financial Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by