量化分析(8)——唐安奇通道

来源:互联网 发布:门口的野蛮人 知乎 编辑:程序博客网 时间:2024/05/22 14:18

唐安奇通道和布林通道差不多,都是判断超买和超卖的工具,我还是喜欢rsi强度来判断超买和超卖,不过这二者可以相互印证一下。这里简单的画一下图,介绍一下。

# -*- coding: utf-8 -*-"""Created on Thu Oct 19 11:23:13 2017@author: Administrator"""import tushare as tsimport pandas as pdimport matplotlib.pyplot as plttsyl_data=ts.get_k_data('000001')tsyl_data.index=tsyl_data.iloc[:,0]tsyl_data.index=pd.to_datetime(tsyl_data.index,format='%Y-%m-%d')#提取收盘价、最低价、最高价my_close=tsyl_data.closemy_low=tsyl_data.lowmy_high=tsyl_data.high#设定上下通道初始值upboundDC=pd.Series(0.0,index=my_close.index)downboundDC=pd.Series(0.0,index=my_close.index)midboundDC=pd.Series(0.0,index=my_close.index)#求唐奇安通道for i in range(20,len(tsyl_data.close)):    upboundDC[i]=max(my_high[(i-20):i])    downboundDC[i]=min(my_low[(i-20):i])    midboundDC[i]=0.5*(upboundDC[i]+downboundDC[i])upboundDC=upboundDC[20:]downboundDC=downboundDC[20:]midboundDC=midboundDC[20:]#绘图plt.rcParams['font.sans-serif']=['SimHei']plt.plot(my_close['2016'],label="close",color='k')plt.plot(upboundDC['2016'],label="up",color='b',linestyle='dashed')plt.plot(downboundDC['2016'],label="down",color='r',linestyle='-')plt.plot(midboundDC['2016'],label="mid",color='b',linestyle='dashed')plt.title("唐奇安通道")plt.legend() 

这里写图片描述
可以从图里看到,大部分情况股价都是在通道之中,所以这个指标也只是参考一下,并不是很好判断趋势。趋势的话,海龟交易法是用来判断趋势的,有兴趣的可以去看看。

阅读全文
0 0