def TSI(df, r, s):
M = pd.Series(df['close'].diff(1))
aM = abs(M)
EMA1 = pd.Series(pd.ewma(M, span = r, min_periods = r - 1))
aEMA1 = pd.Series(pd.ewma(aM, span = r, min_periods = r - 1))
EMA2 = pd.Series(pd.ewma(EMA1, span = s, min_periods = s - 1))
aEMA2 = pd.Series(pd.ewma(aEMA1, span = s, min_periods = s - 1))
TSI = pd.Series(EMA2 / aEMA2, name = 'TSI' + str(r) + '_' + str(s))
return TSI
#Accumulation/Distribution
评论列表
文章目录