gs_quant.timeseries.analysis.lag — gs_quant 0.1 documentation

# gs_quant.timeseries.analysis.lag

`lag`(x, obs=1, mode=<LagMode.EXTEND: 'extend'>)

  Lag timeseries by a number of observations or a relative date.

  Parameters

    - x (`Series`) – timeseries of prices

    - obs (`Union`[`Window`, `int`, `str`]) – non-zero integer (number of observations) or relative date e.g. “-90d”, “1d”, “1m”, “1y”

    - mode (`LagMode`) – whether to extend series index (into the future)

  Return type

    `Series`

  Returns

    date-based time series of return

  Usage

  Shift the series backwards by a specified number of observations:

  \(R_t = X_{t-obs}\)

  where \(obs\) is the number of observations to lag series

  Examples

  Lag series by 2 observations:

      >>> prices = generate_series(100)
      >>> lagged = lag(prices, 2)

  Lag series by 1 year:

      >>> prices = generate_series(100)
      >>> lagged = lag(prices, '1y')

  See also

  `diff()`