original_docstring: Computes the momentum of values.
docstring: Computes the momentum of values.
docstring_tokens: Computes the momentum of values .
code: def momentum(values, window=21):
      'Computes the momentum of values.'
  
      if not isinstance(values, np.ndarray):
          values = values.values
  
      beginning = np.array([float('nan')] * window)
  
      return np.hstack((beginning, values[window:] / values[:-window] - 1))
code_tokens: def momentum ( values , window = 21 ) : if not isinstance ( values , np . ndarray ) : values = values . values beginning = np . array ( [ float ( 'nan' ) ] * window ) return np . hstack ( ( beginning , values [ window : ] / values [ : - window ] - 1 ) )
short_docstring: Computes the momentum of values.
short_docstring_tokens: Computes the momentum of values .
comment: 'Computes the momentum of values.'