General Topics
Markets
Technical Topics
Brokerage Firms
Community Lounge
Site Support

# Modelisation Matlab Greek Option

Discussion in 'Options' started by Masterkint, Sep 24, 2011.

1. ### Masterkint

Dear all,
this is my first thread here. I am currently working on my research paper and I face a big pb.

I want to modelize the "Color" greek option through the use of Matlab and I don't know why but my code seems not to be right.

"clc

disp('Please input the lower and upper bound of the first variable as: [50,150]') ;

disp(' ') ;

para=input('First variable [lower bound, upper bound]=');

while length(para) < 2

disp('Not enough input arguments. Please input in 1*2 vector form like [50,150] or [50 150]');

para=input('First variable [lower bound, upper bound]=');clear

close all

clc

disp('Please input the lower and upper bound of the first variable as: [50,150]') ;

disp(' ') ;

para=input('First variable [lower bound, upper bound]=');

while length(para) < 2

disp('Not enough input arguments. Please input in 1*2 vector form like [50,150] or [50 150]');

para=input('First variable [lower bound, upper bound]=');

end

s1=para(1);

s2=para(2);

disp(' ') ;

disp('Please input the lower and upper bound of the second variable as: [0.05,1]') ;

disp(' ') ;

para=input('Second variable [lower bound, upper bound]=');

while length(para) < 2

disp('Not enough input arguments. Please input in 1*2 vector form like [0.05,1] or [0.05 1]');

para=input('Second variable [lower bound, upper bound]=');

end

t1=para(1);

t2=para(2);

s=100; % stock price

k=100; % exercise price

r=0; % interest rate

v=0.25; % volatility

tau=0.5; % time to maturity

q=0; % dividend rate

steps=100;

[tau,dump] = meshgrid([t1t2-t1)/(steps-1):t2]);

[dump2,S] = meshgrid([s2:-(s2-s1)/(steps-1):s1]);

d1=(log(S./k)+(r-q+v^2/2).*tau)./(v*sqrt(tau));

Volga=(S.*sqrt(tau).*exp(-q.*tau).*normpdf(d1).*d1.*(d1-v.*sqrt(tau)));

H=mesh(tau,S,Volga);

title('Volga')

ylabel('Asset Price S');

xlabel('Time to Maturity tau');

end

s1=para(1);

s2=para(2);

disp(' ') ;

disp('Please input the lower and upper bound of the second variable as: [0.05,1]') ;

disp(' ') ;

para=input('Second variable [lower bound, upper bound]=');

while length(para) < 2

disp('Not enough input arguments. Please input in 1*2 vector form like [0.05,1] or [0.05 1]');

para=input('Second variable [lower bound, upper bound]=');

end

t1=para(1);

t2=para(2);

s=100; % stock price

k=100; % exercise price

r=0; % interest rate

v=0.25; % volatility

tau=0.5; % time to maturity

q=0; % dividend rate

steps=100;

[tau,dump] = meshgrid([t1t2-t1)/(steps-1):t2]);

[dump2,S] = meshgrid([s2:-(s2-s1)/(steps-1):s1]);

d1=(log(S./k)+(r-q+v^2/2).*tau)./(v*sqrt(tau));

d2 = d1 - v*sqrt(tau);

color=-exp(-q*tau)*[normpdf(d1)/2*s*tau*v*sqrt(tau)]*[2*q*tau + 1 + (2*(r-q)*tau-d2*v*sqrt(tau))/v*sqrt(tau)*d1];

H=mesh(tau,S,color);

title('Analyse du Color')

ylabel('Prix du sous-jacent');

I don't know why but Color take to high results...Find attched the mesh file.

If somebody could help me it will be very great.