克隆策略

本周市场,美股A股一齐下跌,沪深300下跌10.08%,标普500下跌5.16%,道指更是两次单日下跌超过1000点。由于美股A股存在高度的相关性,能否利用美股隔夜收益情况,对A股市场投资进行指导呢? 这里针对美股隔夜收益,与A股表现进行相关性分析。

In [1]:
import matplotlib
import scipy
import matplotlib.pyplot as plt

# 读取美股数据
dataM = D.history_data(instruments=['SPX.NYSE'], start_date='2010-01-01', end_date='2018-02-01',fields=['open', 'high', 'low', 'close'])
dataM.index = dataM['date']
dataM.head()
Out[1]:
open close low date instrument high
date
2010-01-04 1116.560059 1132.989990 1116.560059 2010-01-04 SPX.NYSE 1133.869995
2010-01-05 1132.660034 1136.520020 1129.660034 2010-01-05 SPX.NYSE 1136.630005
2010-01-06 1135.709961 1137.140015 1133.949951 2010-01-06 SPX.NYSE 1139.189941
2010-01-07 1136.270020 1141.689941 1131.319946 2010-01-07 SPX.NYSE 1142.459961
2010-01-08 1140.520020 1144.979980 1136.219971 2010-01-08 SPX.NYSE 1145.390015
In [2]:
# 读取A股数据
dataA = D.history_data(instruments=['000300.SHA'], start_date='2010-01-01', end_date='2018-02-01',fields=['open', 'high', 'low', 'close'])
dataA.index = dataA['date']
dataA.head()
Out[2]:
open close low date instrument high
date
2010-01-04 3592.468018 3535.229004 3535.229004 2010-01-04 000300.SHA 3597.748047
2010-01-05 3545.186035 3564.038086 3497.660889 2010-01-05 000300.SHA 3577.525879
2010-01-06 3558.699951 3541.727051 3541.173096 2010-01-06 000300.SHA 3588.832031
2010-01-07 3543.159912 3471.456055 3452.769043 2010-01-07 000300.SHA 3558.555908
2010-01-08 3456.907959 3480.129883 3426.697998 2010-01-08 000300.SHA 3482.083008
In [3]:
# 合并数据
dataA['closeM'] = dataM['close']
dataA.dropna(axis=0, how='any',inplace='True')
dataA.head()
Out[3]:
open close low date instrument high closeM
date
2010-01-04 3592.468018 3535.229004 3535.229004 2010-01-04 000300.SHA 3597.748047 1132.989990
2010-01-05 3545.186035 3564.038086 3497.660889 2010-01-05 000300.SHA 3577.525879 1136.520020
2010-01-06 3558.699951 3541.727051 3541.173096 2010-01-06 000300.SHA 3588.832031 1137.140015
2010-01-07 3543.159912 3471.456055 3452.769043 2010-01-07 000300.SHA 3558.555908 1141.689941
2010-01-08 3456.907959 3480.129883 3426.697998 2010-01-08 000300.SHA 3482.083008 1144.979980
In [4]:
# 计算美股隔夜收益
dataA['dM'] = np.nan
dataA['dM'][1:] = np.array(dataA['closeM'][1:])/np.array(dataA['closeM'][0:-1])-1
dataA.dropna(axis=0, how='any',inplace='True')
dataA.head()
Out[4]:
open close low date instrument high closeM dM
date
2010-01-05 3545.186035 3564.038086 3497.660889 2010-01-05 000300.SHA 3577.525879 1136.520020 0.003116
2010-01-06 3558.699951 3541.727051 3541.173096 2010-01-06 000300.SHA 3588.832031 1137.140015 0.000546
2010-01-07 3543.159912 3471.456055 3452.769043 2010-01-07 000300.SHA 3558.555908 1141.689941 0.004001
2010-01-08 3456.907959 3480.129883 3426.697998 2010-01-08 000300.SHA 3482.083008 1144.979980 0.002882
2010-01-11 3593.105957 3482.052002 3465.316895 2010-01-11 000300.SHA 3594.528076 1146.979980 0.001747
In [5]:
# 分析美股隔夜收益与A股当日收益
hs300closeReturn = np.array(dataA['close'][1:])/np.array(dataA['close'][0:-1])-1
coeff = np.corrcoef(np.array(dataA['dM'][0:-1]), (hs300closeReturn))

fig = plt.figure()
axes = fig.add_axes([1.5, 1.5, 1.5, 1.5])
plt.axis([-8, 8, -8, 8])
plt.plot(100*dataA['dM'][0:-1], 100*hs300closeReturn, '.')
plt.grid(True, color = "k",linestyle =':')
plt.title('SP500 Overnight Returns - HS300 Close Returns')
plt.xlabel('SP500 Overnight Returns(percent)')
plt.ylabel('HS300 Close Returns(percent)')

z2 = np.polyfit(np.array(dataA['dM'][0:-1]), hs300closeReturn, 1)
p = np.poly1d(z2)
fx = scipy.linspace(-8, 8, 1000)
plt.plot(fx, p(fx), linewidth=1)

print  ('SP500隔夜收益与HS300当日收益相关系数:',coeff[1][0])
SP500隔夜收益与HS300当日收益相关系数: 0.154613041377

相关系数达到了0.15,说明美股隔夜收益与A股当日收益相关性明显。 当日收益可以拆分成开盘收益和盘中收益,下面分别分析美股隔夜收益与这两个变量的相关性。

In [6]:
# 分析美股隔夜收益与A股当日开盘收益
hs300openReturn = np.array(dataA['open'][1:])/np.array(dataA['close'][0:-1])-1
coeff = np.corrcoef(np.array(dataA['dM'][0:-1]), (hs300openReturn))

fig = plt.figure()
axes = fig.add_axes([1.5, 1.5, 1.5, 1.5])
plt.axis([-8, 8, -8, 8])
plt.plot(100*dataA['dM'][0:-1], 100*hs300openReturn, '.')
plt.grid(True, color = "k",linestyle =':')
plt.title('SP500 Overnight Returns - HS300 Open Returns')
plt.xlabel('SP500 Overnight Returns(percent)')
plt.ylabel('HS300 Open Returns(percent)')

z2 = np.polyfit(np.array(dataA['dM'][0:-1]), hs300openReturn, 1)
p = np.poly1d(z2)
fx = scipy.linspace(-8, 8, 1000)
plt.plot(fx, p(fx), linewidth=1)

print  ('SP500隔夜收益与HS300开盘收益相关系数:',coeff[1][0])
SP500隔夜收益与HS300开盘收益相关系数: 0.44374820857

可以看出,美股隔夜收益与A股开盘收益高度正相关,相关系数达到0.44。

In [7]:
# 分析美股隔夜收益与A股当日盘中收益
hs300IntradayReturn = np.array(dataA['close'][1:])/np.array(dataA['open'][1:])-1
coeff = np.corrcoef(np.array(dataA['dM'][0:-1]), (hs300IntradayReturn))

fig = plt.figure()
axes = fig.add_axes([1.5, 1.5, 1.5, 1.5])
plt.axis([-8, 8, -8, 8])
plt.plot(100*dataA['dM'][0:-1], 100*hs300IntradayReturn, '.')
plt.grid(True, color = "k",linestyle =':')
plt.title('SP500 Overnight Returns - HS300 Intraday Returns')
plt.xlabel('SP500 Overnight Returns(percent)')
plt.ylabel('HS300 Intraday Returns(percent)')

z2 = np.polyfit(np.array(dataA['dM'][0:-1]), hs300IntradayReturn, 1)
p = np.poly1d(z2)
fx = scipy.linspace(-8, 8, 1000)
plt.plot(fx, p(fx), linewidth=1)

print  ('SP500隔夜收益与HS300当日盘中收益相关系数:',coeff[1][0])
SP500隔夜收益与HS300当日盘中收益相关系数: -0.0481612413755

这里可以看出,美股隔夜收益,与A股盘中收益相关性不高,呈现弱的负相关。 因此,美股隔夜收益的信息,大部分在A股当日开盘价中得到了体现。

如果在当日开盘买入,次日开盘卖出,美股隔夜信息会有怎样的相关性呢?

In [8]:
# 分析美股隔夜收益与A股当日开盘买入次日开盘卖出
hs300dayReturn = np.array(dataA['open'][2:])/np.array(dataA['open'][1:-1])-1
coeff = np.corrcoef(np.array(dataA['dM'][0:-2]), hs300dayReturn)

fig = plt.figure()
axes = fig.add_axes([1.5, 1.5, 1.5, 1.5])
plt.axis([-8, 8, -8, 8])
plt.plot(100*dataA['dM'][0:-2], 100*hs300dayReturn, '.')
plt.grid(True, color = "k",linestyle =':')
plt.title('SP500 Overnight Returns - HS300 Day Returns')
plt.xlabel('SP500 Overnight Returns(percent)')
plt.ylabel('HS300 Day Returns(percent)')

z2 = np.polyfit(np.array(dataA['dM'][0:-2]), hs300dayReturn, 1)
p = np.poly1d(z2)
fx = scipy.linspace(-8, 8, 1000)
plt.plot(fx, p(fx), linewidth=1)

print  ('SP500隔夜收益与HS300当日开盘买入次日开盘卖出收益相关系数:',coeff[1][0])
SP500隔夜收益与HS300当日开盘买入次日开盘卖出收益相关系数: -0.0384487397958

美股隔夜收益与A股当日开盘买入次日开盘卖出,呈现较弱的负相关。

初步分析结论: (1)美股隔夜收益与A股当日收益相关性明显; (2)美股隔夜收益的信息,大部分已经在A股开盘价上得到了体现; (3)美股隔夜收益,与A股盘中走势相关性,明显弱于其与A股开盘收益的相关性。能否利用该信息,还需要进一步研究。