matlab模拟股票价格,MATLAB进行模拟股票价格???

哪位高手帮忙看看下面MATLAB进行模拟股票价格的程序是否有问题啊

function [St]=Stock(T,dt,S0,mu,sigma)

% Simulation of a Stock Price with constant Volatility

clc;

T=input('Specify the desired long time period ');

dt=input('Specify time internals ');

S0=input('Specify the initial Stock Price ');

mu=input('Specify the expected rate of return ');

sigma=input('Specify the volatility ');

%Number of time intervals of length dt in long time period T

N=T/dt;

%Simulation of the stock prices

S=1+mu*(1/N)+sqrt(1/N)*normrnd(0,1,N,1)*sigma;

St=cumprod(S,1);

St=S0*[1;St];

%Plot of the stock prices vs time

k=input('Do you want a graph, Y/N? ','s');

if k=='Y'

for i=1:length(St)

figure(1)

clf

x=0:dt:T;

plot(x(1:i),St(1:i),'b-');

xlim([0 T]);

grid on

xlabel('Time')

ylabel('Stock Prices')

title('Stock Price Simulation (\sigma=35%)')

pause(0.003);

end

else

end

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值