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.