Trinomial option pricing in the maximum of two stocks

3 views (last 30 days)
function [price] = TwoStatesAmericanCallTrinKamradRitchken(strike,S01,S02,irate,TTM,sigma1,sigma2,rho,lamda,N)
% N: how much equal piece Ι divide the time TTM
% S01 & S02 are the initial stock prices
deltaT=TTM/N;
u1=sigma1*lamda*sqrt(deltaT);
u2=sigma2*lamda*sqrt(deltaT);
d1=1/u1;
d2=1/u2;
miu1=irate-((sigma1^2)/2);
miu2=irate-((sigma2^2)/2);
p1=(1/4)*((1/lamda^2)+(sqrt(deltaT)/lamda)*((miu1/sigma1)+(miu2/sigma2))+(rho/lamda^2));
p2=(1/4)*((1/lamda^2)+(sqrt(deltaT)/lamda)*((miu1/sigma1)+(miu2/sigma2))-(rho/lamda^2));
p3=(1/4)*((1/lamda^2)+(sqrt(deltaT)/lamda)*((-miu1/sigma1)+(-miu2/sigma2))+(rho/lamda^2));
p4=(1/4)*((1/lamda^2)+(sqrt(deltaT)/lamda)*((-miu1/sigma1)+(miu2/sigma2))+(rho/lamda^2));
p5=1-(1/lamda^2);
S1Vals=zeros(3*N+4,1); % the values of stock1
S2Vals=zeros(3*N+4,1); % the values of stock2
S1Vals(1)=S01*exp(-N*u1);
S2Vals(1)=S02*exp(-N*u2);
for i=2:3*N+4
S1Vals(i)=exp(u1)*S1Vals(i-1);
S2Vals(i)=exp(u2)*S2Vals(i-1);
end
CVals=zeros(3*N+4,3*N+4); % the value of option
for i=1:2:3*N+4
for j=1:2:3*N+4
CVals(i,j)=max(max(S1Vals(i),S2Vals(i))-strike);
end
end
for tau=0:N
for i=(tau+1):2:(3*N+4-tau)
for j=(tau+1):2:(3*N+4-tau)
CVals(i,j)=exp(-irate*deltaT)*(p1*CVals(i+1,j+1)+p2*CVals(i+1,j-1)+p3*CVals(i-1,j+1)+p4*CVals(i-1,j-i)+p5*CVals(i,j));
end
end
end
price=CVals(N+1,N+1);
Hi everyone. I'm trying to build a code for pricing options with trinomial model, in the maximum of two assets, in our case it's about 2 stocks.
The 2 stocks can go: up-up with probability p1, up-down with probability p2, down-up with probability p3, down-down with probability p4 and stay at the same price with probability p5. Also i have to say that the price of the stock in each node is given as: S01*exp((i-N)*u1 and S02*exp((i-N)*u2.
Then if i try to run: TwoStatesAmericanCallTrinKamradRitchken(35,40,40,0.05,7/12,0.2,0.3,0.5,1.4,10) the price must be approximately 9.420
The problem might be with how i define the matrixes and the dimension.
Any help and advice is acceptable :)

Accepted Answer

Raunak Gupta
Raunak Gupta on 20 Nov 2019
Hi,
From the code I can see that two max are not required in
CVals(i,j)=max(max(S1Vals(i),S2Vals(i))-strike);
as S1Vals and S2Vals are only vector and not matrices.
Also, in
CVals(i,j)=exp(-irate*deltaT)*(p1*CVals(i+1,j+1)+p2*CVals(i+1,j-1)+p3*CVals(i-1,j+1)+p4*CVals(i-1,j-i)+p5*CVals(i,j));
the looping variables can create a problem as (i-1,j-i) will try to access 0 index in CVals array whenever i = j. Try changing the looping variables range for code to run at-least. So, I suggest going through the algorithm again for Trinomial option Pricing for two stocks that you may have referenced while writing above code.
  1 Comment
Violeta Oikonomou
Violeta Oikonomou on 20 Nov 2019
Thanks Raunak for your comment. I 'll try to fix the the looping variables firstly!!

Sign in to comment.

More Answers (0)

Categories

Find more on Price and Analyze Financial Instruments in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!