code: def rolling_returns_cumulative(returns, window, min_periods=1, geometric=True):
      
      if geometric:
          rc = lambda x: (1. + x[np.isfinite(x)]).prod() - 1.
      else:
          rc = lambda x: (x[np.isfinite(x)]).sum()
  
      return pd.rolling_apply(returns, window, rc, min_periods=min_periods)
docs: return the rolling cumulative returns
  
      Parameters
      ----------
      returns : DataFrame or Series
      window : number of observations
      min_periods : minimum number of observations in a window
      geometric : link the returns geometrically