def FISHER(df, n, smooth_p = 0.7, smooth_i = 0.7):
roll_high = pd.rolling_max(df.high, n)
roll_low = pd.rolling_min(df.low, n)
price_loc = (df.close - roll_low)/(roll_high - roll_low) * 2.0 - 1
sm_price = pd.Series(pd.ewma(price_loc, com = 1.0/smooth_p - 1, adjust = False), name = 'FISHER_P')
fisher_ind = 0.5 * np.log((1 + sm_price)/(1 - sm_price))
sm_fisher = pd.Series(pd.ewma(fisher_ind, com = 1.0/smooth_i - 1, adjust = False), name = 'FISHER_I')
return pd.concat([sm_price, sm_fisher], join='outer', axis=1)
评论列表
文章目录