# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import rolling_max [as 别名]
def getKDJ(close, high, low):
'''
calculate KDJ value
:param DataFrame close:close price
:param DataFrame high:highest price of a day
:param DataFrame low: lowest price of a day
:return: [DataFrame,DataFrame,DataFrame,DataFrame] [RSV, K, D, KDJ]:KDJ value and some subproducts
'''
# interval over which KDJ is calculated
kdj_interval = 9
N = 3
# calculate RSV
# get the close value to be used
close = pd.DataFrame(close.iloc[(kdj_interval - 1):, :].values)
# calculate maximum in (kdj_interval) days in high value
high_max_in_interval = pd.rolling_max(high, kdj_interval)
# rolling_sum function will set the first (kdj_interval-1) days as np.nan,drop them
high_max_in_interval.