|
本帖最后由 gyshssl 于 2019-6-18 21:57 编辑
近期在股票操作过程中对成交量,换手率,成交额等与股价未来走势的关系比较感兴趣,因此在优矿中使用python搭建了非常简单的换手率,成交量,成交额等曲线的图形,现将源码做一些演示,仅供参考。(近期刚开始使用python进行量化交易的数据整理)近期在跟踪000099中信海直,感兴趣的朋友也可以一起跟踪。
1.成交量图示:
- import pandas as pd
- import matplotlib.pyplot as plt
- tr = DataAPI.MktEqudGet(secID=u"000099.XSHE",ticker=u"",tradeDate=u"",beginDate=u"20180915",endDate=u"20190618",isOpen="",field="turnoverValue,tradeDate",pandas="1")
- print(tr)
- plt.plot(tr.turnoverValue,linewidth=10)
- plt.show()
复制代码
turnoverVol tradeDate0 2217800 2018-09-171 3028745 2018-09-182 4357603 2018-09-193 3361594 2018-09-204 8576953 2018-09-215 3982300 2018-09-256 3200769 2018-09-267 3450401 2018-09-278 3075300 2018-09-289 2419289 2018-10-0810 2227453 2018-10-0911 1682790 2018-10-1012 7003030 2018-10-1113 4892874 2018-10-1214 2091854 2018-10-1515 2029827 2018-10-1616 2025700 2018-10-1717 1497227 2018-10-1818 1789354 2018-10-1919 4051200 2018-10-2220 2989016 2018-10-2321 1879161 2018-10-2422 1872250 2018-10-2523 2300100 2018-10-2624 1372000 2018-10-2925 2016920 2018-10-3026 2986411 2018-10-3127 4107792 2018-11-0128 5088839 2018-11-0229 4396394 2018-11-05.. ... ...149 3783170 2019-05-07150 3281081 2019-05-08151 2295968 2019-05-09152 5857662 2019-05-10153 2769383 2019-05-13154 3249283 2019-05-14155 3636020 2019-05-15156 5679693 2019-05-16157 7199350 2019-05-17158 4706998 2019-05-20159 3443470 2019-05-21160 2914201 2019-05-22161 2700469 2019-05-23162 2096923 2019-05-24163 2886173 2019-05-27164 3285156 2019-05-28165 2303400 2019-05-29166 2161805 2019-05-30167 2036235 2019-05-31168 2637601 2019-06-03169 2467200 2019-06-04170 1531073 2019-06-05171 2416778 2019-06-06172 2650953 2019-06-10173 3588432 2019-06-11174 2646309 2019-06-12175 2990560 2019-06-13176 3369100 2019-06-14177 1930401 2019-06-17178 1413058 2019-06-18[179 rows x 2 columns]

通过历史成交量图形我们可以看出,到今天该股成交量已经达到近三个季度最低的几个量能位置。在6/18日量能再次的跌破1000万,达到970万,未来
如果量能继续萎缩,则选择方向的实际就将来临。
2.换手率图示:
- import pandas as pd
- import matplotlib.pyplot as plt
- tr = DataAPI.MktEqudGet(secID=u"000099.XSHE",ticker=u"",tradeDate=u"",beginDate=u"20180915",endDate=u"20190618",isOpen="",field="turnoverRate,tradeDate",pandas="1")
- print(tr)
- plt.plot(tr.turnoverRate,linewidth=10)
- plt.show()
复制代码 turnoverRate tradeDate0 0.0037 2018-09-171 0.0050 2018-09-182 0.0072 2018-09-193 0.0055 2018-09-204 0.0142 2018-09-215 0.0066 2018-09-256 0.0053 2018-09-267 0.0057 2018-09-278 0.0051 2018-09-289 0.0040 2018-10-0810 0.0037 2018-10-0911 0.0028 2018-10-1012 0.0116 2018-10-1113 0.0081 2018-10-1214 0.0035 2018-10-1515 0.0033 2018-10-1616 0.0033 2018-10-1717 0.0025 2018-10-1818 0.0030 2018-10-1919 0.0067 2018-10-2220 0.0049 2018-10-2321 0.0031 2018-10-2422 0.0031 2018-10-2523 0.0038 2018-10-2624 0.0023 2018-10-2925 0.0033 2018-10-3026 0.0049 2018-10-3127 0.0068 2018-11-0128 0.0084 2018-11-0229 0.0073 2018-11-05.. ... ...149 0.0062 2019-05-07150 0.0054 2019-05-08151 0.0038 2019-05-09152 0.0097 2019-05-10153 0.0046 2019-05-13154 0.0054 2019-05-14155 0.0060 2019-05-15156 0.0094 2019-05-16157 0.0119 2019-05-17158 0.0078 2019-05-20159 0.0057 2019-05-21160 0.0048 2019-05-22161 0.0045 2019-05-23162 0.0035 2019-05-24163 0.0048 2019-05-27164 0.0054 2019-05-28165 0.0038 2019-05-29166 0.0036 2019-05-30167 0.0034 2019-05-31168 0.0044 2019-06-03169 0.0041 2019-06-04170 0.0025 2019-06-05171 0.0040 2019-06-06172 0.0044 2019-06-10173 0.0059 2019-06-11174 0.0044 2019-06-12175 0.0049 2019-06-13176 0.0056 2019-06-14177 0.0032 2019-06-17178 0.0023 2019-06-18[179 rows x 2 columns]

同样在该位置换手率也出现了非常低的低点,最近变盘是大概率事件。
|
|