def SAR(df, af_step=0.02, af_max=0.2, high='High', low='Low'):
    """
    Parabolic SAR (J. Welles Wilder)
    Returns: list of floats = jhta.SAR(df, af_step=.02, af_max=.2, high='High', low='Low')
    Source: book: New Concepts in Technical Trading Systems
    """
    sar_list = []
    for i in range(len(df[low])):
        if i < 1:
            sar = float('NaN')
            sar_list.append(sar)
            is_long = True
            sar = df[low][i]
            ep = df[high][i]
            af = af_step
        elif is_long:
            if df[low][i] <= sar:
                is_long = False
                sar = ep
                if sar < df[high][i - 1]:
                    sar = df[high][i - 1]
                if sar < df[high][i]:
                    sar = df[high][i]
                sar_list.append(sar)
                af = af_step
                ep = df[low][i]
                sar = sar + af * (ep - sar)
                if sar < df[high][i - 1]:
                    sar = df[high][i - 1]
                if sar < df[high][i]:
                    sar = df[high][i]
            else:
                sar_list.append(sar)
                if df[high][i] > ep:
                    ep = df[high][i]
                    af += af_step
                    if af > af_max:
                        af = af_max
                sar = sar + af * (ep - sar)
                if sar > df[low][i - 1]:
                    sar = df[low][i - 1]
                if sar > df[low][i]:
                    sar = df[low][i]
        elif df[high][i] >= sar:
            is_long = True
            sar = ep
            if sar > df[low][i - 1]:
                sar = df[low][i - 1]
            if sar > df[low][i]:
                sar = df[low][i]
            sar_list.append(sar)
            af = af_step
            ep = df[high][i]
            sar = sar + af * (ep - sar)
            if sar > df[low][i - 1]:
                sar = df[low][i - 1]
            if sar > df[low][i]:
                sar = df[low][i]
        else:
            sar_list.append(sar)
            if df[low][i] < ep:
                ep = df[low][i]
                af += af_step
                if af > af_max:
                    af = af_max
            sar = sar + af * (ep - sar)
            if sar < df[high][i - 1]:
                sar = df[high][i - 1]
            if sar < df[high][i]:
                sar = df[high][i]
    return sar_list
