Bollinger bands

    Returns bolldf, smadf where bolldf is a DataFrame containing
    Bollinger bands with columns 'Upper' and 'Lower' and smadf contains
    the simple moving average.

    Parameters
    ----------
    eqdata : DataFrame
        Must include a column specified in the `selection` parameter or, 
        if no `selection` parameter is given, a column 'Adj Close'.
    window : int, optional
        Lookback period.
    multiple : float, optional
        Multiple of standard deviation above and below sma to use
        in calculating band value. Defaults to 2.0.
    selection : str, optional
        Column of `eqdata` on which to calculate bollinger bands.
        Defaults to 'Adj Close'.

    Returns
    ---------
    bolldf : DataFrame
        Dataframe containing columns 'Upper' and 'Lower' describing
        the given multiple of standard deviations above and below
        simple moving average for the lookback period.
    smadf : DataFrame
        Simple moving average given the specified lookback.

def bollinger(eqdata, **kwargs):
    """ 
    Bollinger bands

    Returns bolldf, smadf where bolldf is a DataFrame containing
    Bollinger bands with columns 'Upper' and 'Lower' and smadf contains
    the simple moving average.

    Parameters
    ----------
    eqdata : DataFrame
        Must include a column specified in the `selection` parameter or, 
        if no `selection` parameter is given, a column 'Adj Close'.
    window : int, optional
        Lookback period.
    multiple : float, optional
        Multiple of standard deviation above and below sma to use
        in calculating band value. Defaults to 2.0.
    selection : str, optional
        Column of `eqdata` on which to calculate bollinger bands.
        Defaults to 'Adj Close'.

    Returns
    ---------
    bolldf : DataFrame
        Dataframe containing columns 'Upper' and 'Lower' describing
        the given multiple of standard deviations above and below
        simple moving average for the lookback period.
    smadf : DataFrame
        Simple moving average given the specified lookback.
    """
    _window = kwargs.get('window', 20)
    _multiple = kwargs.get('multiple', 2.)
    _selection = kwargs.get('selection', 'Adj Close')
    # ensures correct name for output column of sma()
    kwargs['outputcol'] = 'SMA'
    _smadf = sma(eqdata, **kwargs)
    _sigmas = eqdata.loc[:, _selection].rolling(center=False, window=_window).std().values.flatten()
    _diff = _multiple * _sigmas
    _bolldf = pd.DataFrame(index=eqdata.index, columns=['Upper', 'Lower'], dtype=np.float64)
    _bolldf.loc[:, 'Upper'] = _smadf.iloc[:, 0].values + _diff
    _bolldf.loc[:, 'Lower'] = _smadf.iloc[:, 0].values - _diff
    return _bolldf, _smadf