talibpython⽂档_Ta-lib函数⼀览importtkinter as tkfrom tkinter importttkimportmatplotlib.pyplot as pltimportnumpy as npimporttalib as ta
ries= np.random.choice([1, -1], size=200)
clo=np.cumsum(ries).astype(float)#重叠指标
defoverlap_process(event):print(())
overlap=()
upperband, middleband, lowerband= ta.BBANDS(clo, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
fig, axes= plt.subplots(2, 1, sharex=True)
ax1, ax2= axes[0], axes[1]
axes[0].plot(clo,'rd-', markersize=3)
axes[0].plot(upperband,'y-')
axes[0].plot(middleband,'b-')
axes[0].plot(lowerband,'y-')
axes[0].t_title(overlap, fontproperties="SimHei")if overlap == '布林线':pass
忘掉
elif overlap == '双指数移动平均线':
real= ta.DEMA(clo, timeperiod=30)
axes[1].plot(real, 'r-')elif overlap == '指数移动平均线':
real= ta.EMA(clo, timeperiod=30)
axes[1].plot(real, 'r-')elif overlap == '希尔伯特变换——瞬时趋势线':
real=ta.HT_TRENDLINE(clo)
axes[1].plot(real, 'r-')elif overlap == '考夫曼⾃适应移动平均线':
real= ta.KAMA(clo, timeperiod=30)
axes[1].plot(real, 'r-')elif overlap == '移动平均线':
real= ta.MA(clo, timeperiod=30, matype=0)
axes[1].plot(real, 'r-')elif overlap == 'MESA⾃适应移动平均':
mama, fama= ta.MAMA(clo, fastlimit=0, slowlimit=0)
axes[1].plot(mama, 'r-')
axes[1].plot(fama, 'g-')elif overlap == '变周期移动平均线':
real= ta.MAVP(clo, periods, minperiod=2, maxperiod=30, matype=0)
axes[1].plot(real, 'r-')elif overlap == '简单移动平均线':
real= ta.SMA(clo, timeperiod=30)
axes[1].plot(real, 'r-')elif overlap == '三指数移动平均线(T3)':
real= ta.T3(clo, timeperiod=5, vfactor=0)
axes[1].plot(real, 'r-')elif overlap == '三指数移动平均线':
axes[1].plot(real, 'r-')elif overlap == '三⾓形加权法':
real= ta.TRIMA(clo, timeperiod=30)
axes[1].plot(real, 'r-')elif overlap == '加权移动平均数':
real= ta.WMA(clo, timeperiod=30)
axes[1].plot(real, 'r-')
plt.show()#动量指标
defmomentum_process(event):print(())
momentum=()
upperband, middleband, lowerband= ta.BBANDS(clo, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
fig, axes= plt.subplots(2, 1, sharex=True)
ax1, ax2= axes[0], axes[1]
axes[0].plot(clo,'rd-', markersize=3)
axes[0].plot(upperband,'y-')
axes[0].plot(middleband,'b-')
axes[0].plot(lowerband,'y-')
axes[0].t_title(momentum, fontproperties="SimHei")if momentum == '绝对价格振荡器':
real= ta.APO(clo, fastperiod=12, slowperiod=26, matype=0)
axes[1].plot(real, 'r-')elif momentum == '钱德动量摆动指标':
real= ta.CMO(clo, timeperiod=14)
axes[1].plot(real, 'r-')elif momentum == '移动平均收敛/散度':
macd, macdsignal, macdhist= ta.MACD(clo, fastperiod=12, slowperiod=26, signalperiod=9)
axes[1].plot(macd, 'r-')
axes[1].plot(macdsignal, 'g-')
axes[1].plot(macdhist, 'b-')elif momentum == '带可控MA类型的MACD':
圆形的英语macd, macdsignal, macdhist= ta.MACDEXT(clo, fastperiod=12, fastmatype=0, slowperiod=26, slowmatype=0, signalperiod=9, signalmatype=0)
axes[1].plot(macd, 'r-')
axes[1].plot(macdsignal, 'g-')
axes[1].plot(macdhist, 'b-')elif momentum == '移动平均收敛/散度 固定 12/26':
macd, macdsignal, macdhist= ta.MACDFIX(clo, signalperiod=9)
axes[1].plot(macd, 'r-')
axes[1].plot(macdsignal, 'g-')
axes[1].plot(macdhist, 'b-')elif momentum == '动量':
axes[1].plot(real, 'r-')elif momentum == '⽐例价格振荡器':
real= ta.PPO(clo, fastperiod=12, slowperiod=26, matype=0)
axes[1].plot(real, 'r-')elif momentum == '变化率':
real= ta.ROC(clo, timeperiod=10)
axes[1].plot(real, 'r-')elif momentum == '变化率百分⽐':
real= ta.ROCP(clo, timeperiod=10)
axes[1].plot(real, 'r-')elif momentum == '变化率的⽐率':
real= ta.ROCR(clo, timeperiod=10)
axes[1].plot(real, 'r-')elif momentum == '变化率的⽐率100倍':
real= ta.ROCR100(clo, timeperiod=10)蛋糕diy图片
axes[1].plot(real, 'r-')elif momentum == '相对强弱指数':
real= ta.RSI(clo, timeperiod=14)
axes[1].plot(real, 'r-')elif momentum == '随机相对强弱指标':
fastk, fastd= ta.STOCHRSI(clo, timeperiod=14, fastk_period=5, fastd_period=3, fastd_matype=0)
axes[1].plot(fastk, 'r-')
axes[1].plot(fastd, 'r-')elif momentum == '三重光滑EMA的⽇变化率':
real= ta.TRIX(clo, timeperiod=30)
axes[1].plot(real, 'r-')
plt.show()#周期指标
defcycle_process(event):print(())
cycle=()
upperband, middleband, lowerband= ta.BBANDS(clo, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0) fig, axes= plt.subplots(2, 1, sharex=True)
ax1, ax2= axes[0], axes[1]
axes[0].plot(clo,'rd-', markersize=3)
axes[0].plot(upperband,'y-')
axes[0].plot(middleband,'b-')
axes[0].plot(lowerband,'y-')
axes[0].t_title(cycle, fontproperties="SimHei")if cycle == '希尔伯特变换——主要的循环周期':lol意思
real=ta.HT_DCPERIOD(clo)
axes[1].plot(real, 'r-')elif cycle == '希尔伯特变换,占主导地位的周期阶段':
real=ta.HT_DCPHASE(clo)
axes[1].plot(real, 'r-')elif cycle == '希尔伯特变换——相量组件':
inpha, quadrature=ta.HT_PHASOR(clo)
axes[1].plot(inpha, 'r-')
axes[1].plot(quadrature, 'g-')elif cycle == '希尔伯特变换——正弦曲线':
sine, leadsine=ta.HT_SINE(clo)
axes[1].plot(sine, 'r-')
axes[1].plot(leadsine, 'g-')elif cycle == '希尔伯特变换——趋势和周期模式':
integer=ta.HT_TRENDMODE(clo)
axes[1].plot(integer, 'r-')
plt.show()#统计功能
defstatistic_process(event):print(())
statistic=()
upperband, middleband, lowerband= ta.BBANDS(clo, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0) fig, axes= plt.subplots(2, 1, sharex=True)
ax1, ax2= axes[0], axes[1]
axes[0].plot(clo,'rd-', markersize=3)
axes[0].plot(upperband,'y-')
圆的体积怎么算axes[0].plot(middleband,'b-')
axes[0].plot(lowerband,'y-')
axes[0].t_title(statistic, fontproperties="SimHei")if statistic == '线性回归':
real= ta.LINEARREG(clo, timeperiod=14)
axes[1].plot(real, 'r-')elif statistic == '线性回归⾓度':
real= ta.LINEARREG_ANGLE(clo, timeperiod=14)
axes[1].plot(real, 'r-')elif statistic == '线性回归截距':
real= ta.LINEARREG_INTERCEPT(clo, timeperiod=14)
axes[1].plot(real, 'r-')elif statistic == '线性回归斜率':
real= ta.LINEARREG_SLOPE(clo, timeperiod=14)
axes[1].plot(real, 'r-')elif statistic == '标准差':
real= ta.STDDEV(clo, timeperiod=5, nbdev=1)
axes[1].plot(real, 'r-')elif statistic == '时间序列预测':
real= ta.TSF(clo, timeperiod=14)
axes[1].plot(real, 'r-')elif statistic == '⽅差':
real= ta.VAR(clo, timeperiod=5, nbdev=1)
axes[1].plot(real, 'r-')
西安西北大学plt.show()#数学变换
defmath_transform_process(event):print(())
有益摩擦
math_transform=()
upperband, middleband, lowerband= ta.BBANDS(clo, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0) fig, axes= plt.subplots(2, 1, sharex=True)
ax1, ax2= axes[0], axes[1]
axes[0].plot(clo,'rd-', markersize=3)
axes[0].plot(upperband,'y-')
axes[0].plot(middleband,'b-')
axes[0].plot(lowerband,'y-')
axes[0].t_title(math_transform, fontproperties="SimHei")if math_transform == '反余弦':
real=ta.ACOS(clo)
axes[1].plot(real, 'r-')elif math_transform == '反正弦':
real=ta.ASIN(clo)
axes[1].plot(real, 'r-')elif math_transform == '反正切':
real=ta.ATAN(clo)
axes[1].plot(real, 'r-')elif math_transform == '向上取整':
real=ta.CEIL(clo)
axes[1].plot(real, 'r-')elif math_transform == '余弦':
real=ta.COS(clo)
axes[1].plot(real, 'r-')elif math_transform == '双曲余弦':
real=ta.COSH(clo)
axes[1].plot(real, 'r-')elif math_transform == '指数':
real=ta.EXP(clo)
axes[1].plot(real, 'r-')elif math_transform == '向下取整':
real=ta.FLOOR(clo)
axes[1].plot(real, 'r-')elif math_transform == '⾃然对数':
real=ta.LN(clo)
axes[1].plot(real, 'r-')elif math_transform == '常⽤对数':
real=ta.LOG10(clo)背部肌肉酸痛
axes[1].plot(real, 'r-')elif math_transform == '正弦':
real=ta.SIN(clo)
axes[1].plot(real, 'r-')elif math_transform == '双曲正弦':
real=ta.SINH(clo)
axes[1].plot(real, 'r-')elif math_transform == '平⽅根':