Simple simulation of stock price

2 ビュー (過去 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 Center および File ExchangeFinancial Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by