同花顺Supermind量化交易 金融时间序列2--EGARCH模型 附源代码

本文深入探讨了金融时间序列分析,聚焦于EGARCH模型在沪深300收益上的应用。通过导入相关库包,获取并处理数据,建立并分析EGARCH模型,以理解正负市场变动对波动率的影响,并进行拟合和预测。文章提供部分源代码供参考。
摘要由CSDN通过智能技术生成

从金融时间序列的角度,以 沪深 300的收益作为研究标的,使用EGARCH等衍生模型进行探讨和对比,并尝试对价格和波动率进行一定的拟合和预测。

金融时间序列(二)

作者:邱吉尔

1. 输入库包

In [1]:

from scipy import stats
import statsmodels.api as sm
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use('seaborn')
import arch

2. 取出数据

In [2]:

HS300_close=get_price(['000300.SH'], '20151125', '20190125', '1d', ['close'], True, None,is_panel=1)['close']
HS300_close.columns=['HS300_close']
HS300_close['return']=HS300_close['HS300_close'].pct_change()
HS300_close.dropna(inplace=True)
datetime=pd.to_datetime(HS300_close.index)
fig,ax=plt.subplots(figsize=(20,8))
rect1=ax.plot(datetime,HS300_close['return'],color='IndianRed')
ax.set_ylabel('HS300 Return',size=15)
ax=ax.twinx()
rect2=ax.plot(datetime,HS300_close['HS300_close'])
ax.set_ylabel('HS300 Close',size=15)
plt.title('HS300',size=25)

Out[2]:

<matplotlib.text.Text at 0x7fca33a75f60>

3. EGARCH 模型

EGARCH的表达形式:

我们可以看出,正的 at−1 对对数波动率的贡献为:

负的 at−1 对对数波动率的贡献为:

In [143]:

am_EGARCH = arch.arch_model(train_GARCH, mean='AR',lags=14,vol='EGARCH',p=1,o=1,q=1) 
res_EGARCH = am_EGARCH.fit()
res_EGARCH.summary()
Iteration:      1,   Func. Count:     21,   Neg. LLF: -2326.023279716948
Iteration:      2,   Func. Count:     50,   Neg. LLF: -2327.75538643331
Iteration:      3,   Func. Count:     75,   Neg. LLF: -2332.9641537177768
Iteration:      4,   Func. Count:     99,   Neg. LLF: -2336.4718946129
Iteration:      5,   Func. Count:    124,   Neg. LLF: -2337.5857986384435
Iteration:      6,   Func. Count:    149,   Neg. LLF: -2337.8877108788315
Iteration:      7,   Func. Count:    173,   Neg. LLF: -2337.9744306294347
Iteration:      8,   Func. Count:    197,   Neg. LLF: -2338.0061904712775
Iteration:      9,   Func. Count:    221,   Neg. LLF: -2338.0368960602573
Iteration:     10,   Func. Count:    244,   Neg. LLF: -2338.1488006379004
Iteration:     11,   Func. Count:    267,   Neg. LLF: -2339.6189541011254
Iteration:     12,   Func. Count:    291,   Neg. LLF: -2341.2595072472322
Iteration:     13,   Func. Count:    315,   Neg. LLF: -2341.5926887257974
Iteration:     14,   Func. Count:    339,   Neg. LLF: -2341.6206130365963
Iteration:     15,   Func. Count:    361,   Neg. LLF: -2341.9837106155524
Iteration:     16,   Func. Count:    384,   Neg. LLF: -2342.1732119281696
Iteration:     17,   Func. Count:    407,   Neg. LLF: -2342.4738027702338
Iteration:     18,   Func. Count:    431,   Neg. LLF: -2342.6214706160213
Iteration:     19,   Func. Count:    454,   Neg. LLF: -2342.654016464732
Iteration:     20,   Func. Count:    477,   Neg. LLF: -2342.739982087989
Iteration:     21,   Func. Count:    499,   Neg. LLF: -2343.59109155041
Iteration:     22,   Func. Count:    522,   Neg. LLF: -2343.6043663617256
Iteration:     23,   Func. Count:    544,   Neg. LLF: -2344.5256093080343
Iteration:     24,   Func. Count:    569,   Neg. LLF: -2344.629412452444
Iteration:     25,   Func. Count:    591,   Neg. LLF: -2345.7891343356205
Iteration:     26,   Func. Count:    612,   Neg. LLF: -2345.934015219731
Iteration:     27,   Func. Count:    633,   Neg. LLF: -2345.972752691172
Iteration:     28,   Func. Count:    654,   Neg. LLF: -2345.984660670717
Iteration:     29,   Func. Count:    676,   Neg. LLF: -2345.985205294493
Iteration:     30,   Func. Count:    697,   Neg. LLF: -2345.9857837554355
Iteration:     31,   Func. Count:    718,   Neg. LLF: -2345.986178208015
Iteration:     32,   Func. Count:    740,   Neg. LLF: -2345.9862617740637
Iteration:     33,   Func. Count:    763,   Neg. LLF: -2345.9862733237196
Iteration:     34,   Func. Count:    786,   Neg. LLF: -2345.9862797093256
Iteration:     35,   Func. Count:    810,   Neg. LLF: -2345.9862820915555
Optimization terminated successfully.    (Exit mode 0)
            Current function value: -2345.986282829481
            Iterations: 35
            Function evaluations: 814
            Gradient evaluations: 35

Out[143]:

AR - EGARCH Model Results
Dep. Variable: return R-squared: 0.033
Mean Model: AR Adj. R-squared: 0.014
Vol Model: EGARCH Log-Likelihood: 2345.99
Distribution: Normal AIC: -4653.97
Method: Maximum Likelihood BIC: -4566.68
No. Observations: 731
Date: Tue, Feb 12 2019 D
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值