text: # -*- coding: utf-8 -*-
  from .mom import mom
  from ..utils import get_offset, verify_series
  
  def roc(close, length=None, offset=None, **kwargs):
      """Indicator: Rate of Change (ROC)"""
      # Validate Arguments
      close = verify_series(close)
      length = int(length) if length and length > 0 else 10
      min_periods = int(kwargs['min_periods']) if 'min_periods' in kwargs and kwargs['min_periods'] is not None else length
      offset = get_offset(offset)
  
      # Calculate Result
      roc = 100 * mom(close=close, length=length) / close.shift(length)
  
      # Offset
      if offset != 0:
          roc = roc.shift(offset)
  
      # Handle fills
      if 'fillna' in kwargs:
          roc.fillna(kwargs['fillna'], inplace=True)
      if 'fill_method' in kwargs:
          roc.fillna(method=kwargs['fill_method'], inplace=True)
  
      # Name and Categorize it
      roc.name = f"ROC_{length}"
      roc.category = 'momentum'
  
      return roc
  
  
  
  roc.__doc__ = \
  """Rate of Change (ROC)
  
  Rate of Change is an indicator is also referred to as Momentum (yeah, confusingly).
  It is a pure momentum oscillator that measures the percent change in price with the
  previous price 'n' (or length) periods ago.
  
  Sources:
      https://www.tradingview.com/wiki/Rate_of_Change_(ROC)
  
  Calculation:
      Default Inputs:
          length=1
      MOM = Momentum
      ROC = 100 * MOM(close, length) / close.shift(length)
  
  Args:
      close (pd.Series): Series of 'close's
      length (int): It's period.  Default: 1
      offset (int): How many periods to offset the result.  Default: 0
  
  Kwargs:
      fillna (value, optional): pd.DataFrame.fillna(value)
      fill_method (value, optional): Type of fill method
  
  Returns:
      pd.Series: New feature generated.
  """