GARCH(1,1)预测七月份的波动率
vol1=np.zeros(22) #建一个零矩阵存放7月份的预测波动率数据结果
vol1[0]=df2[-5:].std() #用2010年6月25-6月30号的五日均线来估计6月30号的标准差
df_prediction = pro.daily(ts_code='600100.SH', start_date='20100601', end_date='20100731')
df_prediction = df_prediction.loc[:,['trade_date','close']]
df_prediction.index = pd.to_datetime(df_prediction.loc[:,'trade_date'].values)
df_prediction = df_prediction.sort_index()
df_prediction = df_prediction.drop(columns='trade_date') #整理出同方股份的收盘价数据
df_prediction1 = (df_prediction.diff()/df_prediction.shift(1)).dropna() #整理出同方股份的收盘价涨跌幅数据
data7m = df_prediction[-22:] #取出7月的收益率数据,用来代入garch模型
for i in range(21):
vol1[i+1]=np.sqrt(0.000151+0.10*data7m.iloc[i]*2+0.77vol1[i]**2)
得出来是这21天每日波动率的数组,而不是这个月的波动率,那么这个月的波动率怎么求呢?