close与volume的相关性
观察002045,2017年以来close与volume的相关性,代码如下:
import matplotlib.pyplot as plt import tushare as ts data = ts.get_h_data('002045',start='2017-01-01',end='2017-11-30') data = data.sort_index(axis=0, ascending=True) a = data.close b = data.volume d = data.index c = a.corr(b) plt.subplot(2,1,1) plt.ylabel('close') plt.plot(d,a,color='red') plt.subplot(2,1,2) plt.ylabel('volume') plt.plot(d,b,color='green') plt.show()
其中相关性C值为,显示为无相关性:
[Getting data:]###>>> c
-0.021570976635901289
使用matplotlib在同一张图上绘制close,volume,如下: