original_docstring: Calculates the volatility in a fixed period.
docstring: Calculates the volatility in a fixed period.
docstring_tokens: Calculates the volatility in a fixed period .
code: def volatility(values, period=TRADING_DAYS_IN_YEAR):
      'Calculates the volatility in a fixed period.'
  
      if not isinstance(values, np.ndarray):
          values = values.values
  
      head = np.array([float('nan')] * period)
  
      tail = np.array([
          historical_volatility(values[i:i + period])
          for i in range(len(values) - period)
      ])
  
      return np.hstack((head, tail))
code_tokens: def volatility ( values , period = TRADING_DAYS_IN_YEAR ) : if not isinstance ( values , np . ndarray ) : values = values . values head = np . array ( [ float ( 'nan' ) ] * period ) tail = np . array ( [ historical_volatility ( values [ i : i + period ] ) for i in range ( len ( values ) - period ) ] ) return np . hstack ( ( head , tail ) )
short_docstring: Calculates the volatility in a fixed period.
short_docstring_tokens: Calculates the volatility in a fixed period .
comment: 'Calculates the volatility in a fixed period.'