关于ta-lib安装包

2021/11/15 23:10:39

本文主要是介绍关于ta-lib安装包,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

关于ta-lib安装包

  • 1.市场指标计算
    • 1.1 MA指标
    • 1.2 MACD指标
    • 1.3 RSI指标
    • 1.4 KDJ指标
    • 1.5 CCI指标
    • 1.6 ATR指标
    • 1.7 OBV指标

1.市场指标计算

1.1 MA指标

import talib
import pandas as pd
import mplfinance as mpf
import matplotlib.pyplot as plt
#from matplotlib.finance import candlestick2_ohlc
from mpl_finance import candlestick2_ohlc
from mpl_finance import candlestick_ohlc
#pip install https://github.com/matplotlib/mpl_finance/archive/master.zip

df = pd.read_csv('./000001.SZ.csv')
ma5_df=talib.MA(df['close'],timeperiod=5)
#print(ma_df)
ma10_df=talib.MA(df['close'],timeperiod=10)
ma20_df=talib.MA(df['close'],timeperiod=20)

fig=plt.figure()
ax=fig.add_subplot(111)
ax.plot(ma5_df,label='MA5')
ax.plot(ma10_df,label='MA10')
ax.plot(ma20_df,label='MA20')
candlestick2_ohlc(ax,df['open'],df['high'],df['low'],df['close'],width=0.6,colorup='red',colordown='green')
plt.legend()
plt.show()

1.2 MACD指标

diff ,dea,macd=talib.MACD(df['close'],fastperiod=12,slowperiod=26,signalperiod=9)

1.3 RSI指标

rsi=tailb.RSI(df['close'],timeperiod=14)

1.4 KDJ指标

K,D=talib.STOCH(df['high'],df['low'],df['close'],fastk_period=9,slowk_period=3,slowd_period=3)

1.5 CCI指标

CCI=talib.CCI(df['high'],df['low'],df['close'],timeperiod=14)

1.6 ATR指标

ATR=talib.ATR(df['high'],df['low'],df['close'],timeperiod=14)

1.7 OBV指标

OBV=talib.OBV(df['close'],df['vol'])

待更新。。。



这篇关于关于ta-lib安装包的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程