同步
fts=ascii2fts('C:\Users\Administrator\Desktop\2015141464016.txt',1,2,0);%
%%文件导入
fts_matrix=fts2mat(fts);%%转为矩阵形式
plot(fts_matrix(1:100,4),'r'); hold on;
candle(fts_matrix(1:100,2),fts_matrix(1:100,3),fts_matrix(1:100,4),ft
s_matrix(1:100,1),'b');%%%绘制 K线图
grid on;
ret=price2ret(fts_matrix(1:120,4));%%%将收盘价转换为对数收益率
adftest(ret)%%%单位根检验
autocorr(ret);%%%%绘制 ACF图
parcorr(ret);%%%绘制 PACF图
m=armax(ret,'na',1,'nc',2); fpe(m) armax(ret,'na',1,'nc',2)
spec1=garchset('R',0,'M',0,'P',1,'Q',1,'Display','off');%%设置
ARMA-GARCH模型
[coeff1,error1,llf1,innovation1,sigma1]=garchfit(spec1,ret); garchdisp(coeff1,error1)
spec2=garchset('R',0,'M',1,'P',1,'Q',1,'Display','off');%%设置
ARMA-GARCH模型
[coeff2,error2,llf2,innovation2,sigma2]=garchfit(spec2,ret); garchdisp(coeff2,error2)
[E,Sigma,Y] = garchsim(coeff1,20,1);%%%仿真
intimate_price=ret2price(Y); ret1=price2ret(fts_matrix(121:end,4)); real_price=ret2price(ret1); plot(intimate_price,'b');
hold on; plot(real_price,'r'); grid on;
legend('仿真价格','真实价格');