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()
diff ,dea,macd=talib.MACD(df['close'],fastperiod=12,slowperiod=26,signalperiod=9)
rsi=tailb.RSI(df['close'],timeperiod=14)
K,D=talib.STOCH(df['high'],df['low'],df['close'],fastk_period=9,slowk_period=3,slowd_period=3)
CCI=talib.CCI(df['high'],df['low'],df['close'],timeperiod=14)
ATR=talib.ATR(df['high'],df['low'],df['close'],timeperiod=14)
OBV=talib.OBV(df['close'],df['vol'])
待更新。。。