Simple simulation of stock price

2 visualizaciones (últimos 30 días)
N/A
N/A el 18 de Ag. de 2017
Comentada: N/A el 18 de Ag. de 2017
I am new with MATLAB. Could you help out with simulating X amount of what is inside the loop?
r = 0.02;
sigma = .2;
S_0 = 10;
dt = 1/4000;
wp = sqrt(dt);
S_1 = S_0*(1+r*dt+sigma*wp*normrnd(0,1));
for i = 1:1000
S_1 = S_1*(1+r*dt+sigma*wp*normrnd(0,1));
end
disp(S_1)
  1 comentario
Image Analyst
Image Analyst el 18 de Ag. de 2017
What do you mean by "X amount"? I don't see any variable X in the code either. And by "what is inside the loop" do you mean S_1? If X is some fraction, then X amount of S_1 is simply X*S_1.

Iniciar sesión para comentar.

Respuestas (1)

Kuifeng
Kuifeng el 18 de Ag. de 2017
In the loop, does this answer to your question?
for i = 1:1000
S_1(i+1) = S_1(i)*(1+r*dt+sigma*wp*normrnd(0,1));
end
  1 comentario
N/A
N/A el 18 de Ag. de 2017
Thanks, These three lines generate stock price after 1000 steps. I need to generate, for example, 10000 of these stock prices. Because, as I understand, your answer gives a vector with just the history of getting to that 1000th value. So, basically I need 10000 stock prices after 1000 steps.

Iniciar sesión para comentar.

Categorías

Más información sobre Financial Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by