关于ta-lib安装包
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'])
待更新。。。