def _plot_bollinger_bands(data, axes, period = 50, bandwidth = 1): _check_int(period, raise_err = True) _check_int(bandwidth, raise_err = True) _check_pandas_series(data, raise_err = True) lowr, mean, uppr = _get_bollinger_bands(data, period = period, bandwidth = bandwidth) axes.plot(lowr, color = 'r', linestyle = '--') axes.plot(mean, color = 'g', linestyle = '--') axes.plot(uppr, color = 'r', linestyle = '--')
def _get_bollinger_bands(data, period=50, bandwidth=1): _check_int(period, raise_err=True) _check_int(bandwidth, raise_err=True) _check_pandas_series(data, raise_err=True) roll = data.rolling(window=period) std, mean = roll.std(), roll.mean() upper = mean + bandwidth * std lower = mean - bandwidth * std return (lower, mean, upper)
def _get_bollinger_bands(data, period = 50, bandwidth = 1): _check_int(period, raise_err = True) _check_int(bandwidth, raise_err = True) _check_pandas_series(data, raise_err = True) roll = data.rolling(window = period) std, mean = roll.std(), roll.mean() upper = mean + bandwidth * std lower = mean - bandwidth * std return (lower, mean, upper)
def _plot_global_mean(data, axes): _check_pandas_series(data, raise_err=True) mean = data.mean() axes.axhline(mean, color='b', linestyle='-.')
def _plot_global_mean(data, axes): _check_pandas_series(data, raise_err = True) mean = data.mean() axes.axhline(mean, color = 'b', linestyle = '-.')