# -*- coding: utf-8 -*- """ Created on Thu Jun 22 17:03:16 2017 @author: yunjinqi E-mail:yunjinqi@qq.com Differentiate yourself in the world from anyone else. """ import pandas as pd import numpy as np import matplotlib.pyplot as plt import statsmodels.tsa.stattools as ts import statsmodels.api as sm from statsmodels.graphics.api import qqplot namelist=['cu','al','zn','pb','sn','au','ag','rb','hc','bu','ru','m9','y9','a9', 'p9','c9','cs','jd','l9','v9','pp','j9','jm','i9','sr','cf', 'zc','fg','ta','ma','oi','rm','sm'] j=0 for i in namelist: filename='C:/Users/HXWD/Desktop/数据/'+i+'.csv' data=pd.read_csv(filename,encoding='gbk') data.columns=['date','open','high','low','close','amt','opi'] data.head() data=np.log(data['close']) r=data-data.shift(1) r=r.dropna() #print(r) x = np.array(r) print(i) lag_acf = acf(x, nlags=40) lag_pacf = pacf(x, nlags=40, method='ols') fig = plt.figure(figsize=(12,8)) ax1=fig.add_subplot(211) print(lag_acf) fig = sm.graphics.tsa.plot_acf(x,lags=40,ax=ax1) ax2 = fig.add_subplot(212) print(lag_pacf) fig = sm.graphics.tsa.plot_pacf(x,lags=40,ax=ax2) plt.show()
33期货品种指数的对数收益率的自相关检验,基本上不存在自相关。