[关闭]
@CLSChen 2019-06-19T08:33:10.000000Z 字数 957 阅读 698

同步

  1. fts=ascii2fts('C:\Users\Administrator\Desktop\2015141464016.txt',1,2,0);%
  2. %%文件导入
  3. fts_matrix=fts2mat(fts);%%转为矩阵形式
  4. plot(fts_matrix(1:100,4),'r'); hold on;
  5. candle(fts_matrix(1:100,2),fts_matrix(1:100,3),fts_matrix(1:100,4),ft
  6. s_matrix(1:100,1),'b');%%%绘制 K线图
  7. grid on;
  8. ret=price2ret(fts_matrix(1:120,4));%%%将收盘价转换为对数收益率
  9. adftest(ret)%%%单位根检验
  10. autocorr(ret);%%%%绘制 ACF
  11. parcorr(ret);%%%绘制 PACF
  12. m=armax(ret,'na',1,'nc',2); fpe(m) armax(ret,'na',1,'nc',2)
  13. spec1=garchset('R',0,'M',0,'P',1,'Q',1,'Display','off');%%设置
  14. ARMA-GARCH模型
  15. [coeff1,error1,llf1,innovation1,sigma1]=garchfit(spec1,ret); garchdisp(coeff1,error1)
  16. spec2=garchset('R',0,'M',1,'P',1,'Q',1,'Display','off');%%设置
  17. ARMA-GARCH模型
  18. [coeff2,error2,llf2,innovation2,sigma2]=garchfit(spec2,ret); garchdisp(coeff2,error2)
  19. [E,Sigma,Y] = garchsim(coeff1,20,1);%%%仿真
  20. intimate_price=ret2price(Y); ret1=price2ret(fts_matrix(121:end,4)); real_price=ret2price(ret1); plot(intimate_price,'b');
  21. hold on; plot(real_price,'r'); grid on;
  22. legend('仿真价格','真实价格');
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注