import pandas as pd
import numpy as np
import tushare as ts
import matplotlib.pyplot as plt
import seaborn as sns
from scipy import stats
sh=ts.get_hist_data('sh').sort_index()
sh['re']=np.log(sh['close']/sh['close'].shift(1))
sh=sh.dropna()
sns.distplot(sh['re'])
remean=sh['re'].mean()
restd=sh['re'].std()
stats.t.interval(置信度,自由度,均值,标准误) #求解置信区间
stats.t.interval(0.95,len(sh['re'])-1,remean,stats.sem(restd))