楼主: lhsfs
6454 2

[问答] MATLAB进行模拟股票价格??? [推广有奖]

  • 0关注
  • 0粉丝

本科生

22%

还不是VIP/贵宾

-

威望
0
论坛币
-5514 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
-190 点
帖子
57
精华
0
在线时间
0 小时
注册时间
2005-9-10
最后登录
2016-1-19

楼主
lhsfs 发表于 2006-5-26 21:57:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

哪位高手帮忙看看下面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

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:MATLAB atlab matla 股票价格 Lab MATLAB 模拟 股票价格

本帖被以下文库推荐

沙发
stone_dl168 发表于 2006-6-28 11:12:00

看不出什么问题,我运行了一下,没图的。

藤椅
zhangader 在职认证  发表于 2006-7-1 08:07:00

1、pause(0.003);时间太短,建议改为0。1
2、x=0:dt:T;放在循环里,浪费资源

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

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-28 14:24