Simple simulation of stock price

1 次查看(过去 30 天)
N/A
N/A 2017-8-18
评论: N/A 2017-8-18
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 个评论
Image Analyst
Image Analyst 2017-8-18
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.

请先登录,再进行评论。

回答(1 个)

Kuifeng
Kuifeng 2017-8-18
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 个评论
N/A
N/A 2017-8-18
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Financial Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by