code: def SMA(Series, N, M=1):
      
      ret = []
      i = 1
      length = len(Series)
      # 跳过X中前面几个 nan 值
      while i < length:
          if np.isnan(Series.iloc[i]):
              i += 1
          else:
              break
      preY = Series.iloc[i]  # Y'
      ret.append(preY)
      while i < length:
          Y = (M * Series.iloc[i] + (N - M) * preY) / float(N)
          ret.append(Y)
          preY = Y
          i += 1
      return pd.Series(ret, index=Series.tail(len(ret)).index)
docs: 威廉SMA算法
  
      本次修正主要是对于返回值的优化,现在的返回值会带上原先输入的索引index
      2018/5/3
      @yutiansut