人民币对澳元汇率的大数据分析与预测

import pandas as pd
import matplotlib.pyplot as plt
import statsmodels as sm
from statsmodels.graphics.tsaplots import plot_acf,plot_pacf
import numpy as np

discfile = r'D:\python\日线数据\renminbi_ouyuan.xlsx'
forecastnum = 5
data = pd.read_excel(discfile, index_col = '时间')
data = data['']
data
plt.rcParams['font.sans-serif'] = ['SimHei']
##datetime时间转化
data.index = pd.to_datetime(data.index,format="%Y/%m/%d")
plt.figure(figsize=(8,4))
plt.plot(data)
plt.show()
##ACF,PACF计算
fig = plt.figure(figsize = (12,8))
ax1 = fig.add_subplot(211)
fig = plot_acf(data,lags = 40,ax =ax1)
ax1.xaxis.set_ticks_position('bottom')
fig.tight_layout()
ax2 = fig.add_subplot(212)
fig = plot_pacf(data,lags = 40,ax =ax2)
ax1.xaxis.set_ticks_position('bottom')
fig.tight_layout()

data_diff = data.diff(5)
data_diff = data_diff.dropna()

##差分后ACF,PACF计算
fig = plt.figure(figsize = (12,8))
ax1 = fig.add_subplot(211)
fig = plot_acf(data_diff,lags = 40,ax =ax1)
ax1.xaxis.set_ticks_position('bottom')
fig.tight_layout()
ax2 = fig.add_subplot(212)
fig = plot_pacf(data_diff,lags = 40,ax =ax2)
ax1.xaxis.set_ticks_position('bottom')
fig.tight_layout()

arima11 = sm.tsa.arima_model.ARMA(data_diff,order=(6,4))
model_results=arima11.fit()
predict = model_results.predict()
forecast = model_results.forecast(5)
plt.figure(figsize=(12,8))
plt.plot(data_diff.iloc[data_diff.size-1000:data_diff.size])
plt.plot(predict[data_diff.size-1000:data_diff.size],'r')
plt.show()

 

转载于:https://www.cnblogs.com/ggzjf/p/10145781.html

你可能感兴趣的:(人民币对澳元汇率的大数据分析与预测)