bollinger_bands¶
-
bollinger_bands
(x, w=Window(w=None, r=0), k=2)[source]¶ Bollinger bands with given window and width
- Parameters
x (
Series
) – time series of pricesw (
Union
[Window
,int
]) – Window or int: number of observations and ramp up to use. e.g. Window(22, 10) where 22 is the window size
and 10 the ramp up value. Window size defaults to length of series. :type k:
float
:param k: band width in standard deviations (default: 2) :rtype:DataFrame
:return: date-based time series of returnUsage
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()