时间序列量化分析_01

data = pd.read_csv("Nasdaq_daily.csv", header=0)
dt = data.iloc[::-1]#将顺序颠倒,原数据日期由近到远
#print(dt)
#plt.plot(dt['Close'])
#plt.show()
daily_returns = dt['Close'].pct_change()*100# calculate simple return
daily_logreturns = (np.log(dt['Close']) - np.log(dt['Close'].shift(1)))*100
'''
fig = plt.figure()
#print(daily_returns, daily_logreturns)
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212)
ax3 = fig.add_subplot(212)
ax1.plot(daily_returns, label='daily simple return')
ax1.legend()
ax2.plot(daily_logreturns, label= 'daily_logreturns')
ax2.legend()
ax3.plot(daily_returns-daily_logreturns, label='daily simple return minus log return')
ax3.legend()
plt.tight_layout()
plt.show()
plt.close()'''

#Compute the summary statistics
#daily_returns
#daily_logreturns
#print(daily_returns.describe())
n = len(daily_returns)-1
s1 = stats.skew(daily_returns[1:]) # NaN for the first data
t1 = s1/np.sqrt(6/n) #Compute test statistic
pval = (1-stats.t.sf(t1, n-1))*2
print(pval)
#The result shows that the hypothesis of zero expected return can be rejected at the 5%  level.

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值