def dmi(arg, n, high_col='high', low_col='low', close_col='close'):
    """ Return the dmi+, dmi-, Average directional index
    ( http://en.wikipedia.org/wiki/Average_Directional_Index )
        TODO - break up calcuat
    """
    converted = arg[[close_col, high_col, low_col]]
    converted.columns = ['close', 'high', 'low']

    up_mv = converted.high.diff()
    dn_mv = -1 * converted.low.diff()
    up_mv[~((up_mv > 0) & (up_mv > dn_mv))] = 0
    dn_mv[~((dn_mv > 0) & (dn_mv > up_mv))] = 0

    tr = true_range(converted, 'high', 'low', 'close')
    atr = wilderma(tr, n)

    di_pos = 100. * wilderma(up_mv, n) / atr
    di_neg = 100. * wilderma(dn_mv, n) / atr
    dx = 100. * np.abs(di_pos - di_neg) / (di_pos + di_neg)
    adx = wilderma(dx, n)

    data = [
        ('DI+', di_pos),
        ('DI-', di_neg),
        ('DX', dx),
        ('ADX', adx),
    ]
    return pd.DataFrame.from_items(data)
def dmi ( arg , n , high_col = 'high' , low_col = 'low' , close_col = 'close' ) : converted = arg [ [ close_col , high_col , low_col ] ] converted . columns = [ 'close' , 'high' , 'low' ] up_mv = converted . high . diff ( ) dn_mv = - 1 * converted . low . diff ( ) up_mv [ ~ ( ( up_mv > 0 ) & ( up_mv > dn_mv ) ) ] = 0 dn_mv [ ~ ( ( dn_mv > 0 ) & ( dn_mv > up_mv ) ) ] = 0 tr = true_range ( converted , 'high' , 'low' , 'close' ) atr = wilderma ( tr , n ) di_pos = 100. * wilderma ( up_mv , n ) / atr di_neg = 100. * wilderma ( dn_mv , n ) / atr dx = 100. * np . abs ( di_pos - di_neg ) / ( di_pos + di_neg ) adx = wilderma ( dx , n ) data = [ ( 'DI+' , di_pos ) , ( 'DI-' , di_neg ) , ( 'DX' , dx ) , ( 'ADX' , adx ) , ] return pd . DataFrame . from_items ( data )
Return the dmi+, dmi-, Average directional index
    ( http://en.wikipedia.org/wiki/Average_Directional_Index )
        TODO - break up calcuat