text: import numpy  
  import pandas as pd  
  import math as m
  
  
  
  #Momentum  
  def MOM(df, n):  
      M = pd.Series(df['Close'].diff(n), name = 'Momentum_' + str(n))  
      df = df.join(M)  
      return df
  
  #Rate of Change  
  def ROC(df, n):  
      M = df['Close'].diff(n - 1)  
      N = df['Close'].shift(n - 1)  
      ROC = pd.Series(M / N, name = 'ROC_' + str(n))  
      df = df.join(ROC)  
      return df
  