gs_quant.timeseries.technicals.bollinger_bands — gs_quant 0.1 documentation

# gs_quant.timeseries.technicals.bollinger_bands

`bollinger_bands`(x, w=<gs_quant.timeseries.helper.Window object>, k=2)

  Bollinger bands with given window and width

  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.

    - k (`float`) – band width in standard deviations (default: 2)

  Return type

    `DataFrame`

  Returns

    date-based time series of return

  Usage

  Standard deviation bands around the moving average of asset price level. Bollinger bands can be used to determine a range around the price level which responds to local volatility changes. Returns two series, upper, \(u_t\) and lower, \(l_t\)

  \(u_t = \bar{X_t} + k\sigma_t\)

  \(l_t = \bar{X_t} - k\sigma_t\)

  where \(\bar{X_t}\) is the moving average over specified window, and \(\sigma_t\) is the rolling standard deviation over the specified window

  See Bollinger Bands for more information

  Examples

  Compute bollinger bands around \(20\) day moving average at \(2\) standard deviations:

      >>> prices = generate_series(100)
      >>> bollinger_bands(prices, 20, 2)

  See also

  `moving_average()` `std()`