code: def rolling_vwap(bars, window=200, min_periods=None):
      
      min_periods = window if min_periods is None else min_periods
  
      typical = ((bars['high'] + bars['low'] + bars['close']) / 3)
      volume = bars['volume']
  
      left = (volume * typical).rolling(window=window,
                                        min_periods=min_periods).sum()
      right = volume.rolling(window=window, min_periods=min_periods).sum()
  
      return pd.Series(index=bars.index, data=(left / right)).replace([np.inf, -np.inf], float('NaN')).ffill()
docs: calculate vwap using moving window
      (input can be pandas series or numpy array)
      bars are usually mid [ (h+l)/2 ] or typical [ (h+l+c)/3 ]