code: def moving_average(data, periods, type='simple'):
      
      data = np.asarray(data)
      if type == 'simple':
          weights = np.ones(periods)
      else:
          weights = np.exp(np.linspace(-1., 0., periods))
  
      weights /= weights.sum()
  
      mavg = np.convolve(data, weights, mode='full')[:len(data)]
      mavg[:periods] = mavg[periods]
      return mavg
docs: compute a <periods> period moving average.
      type is 'simple' | 'exponential'