def calKdj(df):
    low_list = df['low'].rolling(9, min_periods=9).min()
    low_list.fillna(value=df['low'].expanding().min(), inplace=True)
    high_list = df['high'].rolling(9, min_periods=9).max()
    high_list.fillna(value=df['high'].expanding().max(), inplace=True)
    rsv = (df['close'] - low_list) / (high_list - low_list) * 100
 
    df['K'] = pd.Series.ewm(rsv, com=2).mean()
    df['D'] = pd.Series.ewm(df['K'], com=2).mean()
    df['J'] = 3 * df['K'] - 2 * df['D']

    return df

 

相关文章:

  • 2021-07-14
  • 2022-12-23
  • 2021-07-28
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2021-05-10
猜你喜欢
  • 2021-12-30
  • 2021-12-24
  • 2021-12-30
  • 2021-12-30
  • 2021-11-12
  • 2021-04-04
  • 2021-10-24
相关资源
相似解决方案