SAR #talib里的sar算出来的值和图表上看数值的差异不小,不过好在我对比了好几个软件数值上都差的蛮多的,这里python算来的序列数据从趋势涨跌来看还是吻合的。 #建议使用前自己对比下再 num = -1 # 在context中保存全局变量 high = history_bars('RB00',100,'1d','high',include_now=True) low = history_bars('RB00',100,'1d','low',include_now=True) #acceleration表示步长,maximum表示极限值 sar = talib.SAR(high,low,acceleration=0.02, maximum=0.2) print(sar) |
RSI强弱指标
num = -1
close = history_bars('RB00',100,'1d','close',include_now=True)
#就一个周期参数就行了
rsi = talib.RSI(close,timeperiod=6)
print(rsi[num])
威廉指标
num = -1
close = history_bars('RB00',100,'1d','close',include_now=True)
high = history_bars('RB00',100,'1d','high',include_now=True)
low = history_bars('RB00',100,'1d','low',include_now=True)
will = talib.WILLR(high,low,close,timeperiod=14)
print(will[num])
TRIX三重指数平均
num = -1
close = history_bars('RB00',100,'1d','close',include_now=True)
trix = talib.TRIX(close,timeperiod=12)
print(trix[num])
TR真实波幅
num = -1
close = history_bars('RB00',100,'1d','close',include_now=True)
high = history_bars('RB00',100,'1d','high',include_now=True)
low = history_bars('RB00',100,'1d','low',include_now=True)
tr = talib.TRANGE(high,low,close)
print(tr)
#tr的均值就是我们常用的atr指标。talib自带的有atr不过计算出来的值和图表不对,所以我这里计算tr然后均值得到的就一样了
print(talib.SMA(tr,14))
|
|