Python计算KDJ值

时间:2024-03-12 07:42:50

Python计算KDJ值,但计算的结果跟通达信软件有一定的差别。

import talib as ta
import tushare as ts
import pandas as pd
dw = ts.get_k_data("601069")
print(dw)
dw = dw[60:]
dw.index = range(len(dw))
dw[\'slowk\'], dw[\'slowd\']  = ta.STOCH(dw[\'high\'].values, dw[\'low\'].values, dw[\'close\'].values, fastk_period=9, slowk_period=3, slowk_matype=1, slowd_period=3, slowd_matype=1)
df = pd.DataFrame(data=dw)
row = df.iloc[-10:].values
print(row)