Volatility (standard deviation) over the given window

    Parameters
    ----------
    eqdata : DataFrame
    window : int, optional
        Lookback period. Defaults to 20.
    outputcol : str, optional
        Name of column to be used in returned dataframe. Defaults to 'Risk'.
    selection : str, optional
        Column of eqdata on which to calculate volatility. If
        `eqdata` has only 1 column, `selection` is ignored,
        and volatility is calculated on that column. Defaults
        to 'Adj Close'.

    Returns
    ---------
    risk : DataFrame
        Moving volatility with the given lookback.

def volatility(eqdata, **kwargs):
    """
    Volatility (standard deviation) over the given window

    Parameters
    ----------
    eqdata : DataFrame
    window : int, optional
        Lookback period. Defaults to 20.
    outputcol : str, optional
        Name of column to be used in returned dataframe. Defaults to 'Risk'.
    selection : str, optional
        Column of eqdata on which to calculate volatility. If
        `eqdata` has only 1 column, `selection` is ignored,
        and volatility is calculated on that column. Defaults
        to 'Adj Close'.

    Returns
    ---------
    risk : DataFrame
        Moving volatility with the given lookback.
    """
    if len(eqdata.shape) > 1 and eqdata.shape[1] != 1:
        _selection = kwargs.get('selection', 'Adj Close')
        _eqdata = eqdata.loc[:, _selection]
    else:
        _eqdata = eqdata
    _window = kwargs.get('window', 20)
    _colname = kwargs.get('outputcol', 'Risk')
    _risk = pd.DataFrame(index=_eqdata.index, columns=[_colname], dtype=np.float64)
    _risk.loc[:, _colname] = _eqdata.rolling(center=False, window=_window).std().values.flatten()
    return _risk