gs_quant.timeseries.technicals.moving_average — gs_quant 0.1 documentation

# gs_quant.timeseries.technicals.moving_average

`moving_average`(x, w=<gs_quant.timeseries.helper.Window object>)

  Moving average over specified window

  Parameters

    - x (`Series`) – time series of prices

    - w (`Union`[`Window`, `int`, `str`]) – Window or int: size of window and ramp up to use. e.g. Window(22, 10) where 22 is the window size and 10 the ramp up value. If w is a string, it should be a relative date like ‘1m’, ‘1d’, etc. Window size defaults to length of series.

  Return type

    `Series`

  Returns

    date-based time series of return

  Usage

  Simple arithmetic moving average over the specified window (number of observations). Shorter windows will be more reactive to changes in the asset price, but more volatile. Larger windows will be smoother but less reactive to near term changes in asset prices.

  \(R_t = \frac{\sum_{i=t-w+1}^{t} X_t}{N}\)

  where N is the number of observations in each rolling window, \(w\). If window is not provided, computes rolling mean over the full series

  Equivalent to `mean`

  Examples

  Generate price series with 100 observations starting from today’s date:

      >>> prices = generate_series(100)
      >>> moving_average(prices, 22)

  See also

  `mean()`