def winning_trade_test(hd1, hd2, n=20, offset=20):
    """
    Alternative to bounded_roi for determing class of trade.
    Returns 1 iff the shorted position decreased AND the long position increased.
    """
    #Calculate percent gain in hd1 and hd2 to determine which would be shorted
    pg1 = (hd1.close[offset] - hd1.close[offset+n]) / hd1.close[offset+n]
    pg2 = (hd2.close[offset] - hd2.close[offset+n]) / hd2.close[offset+n]
    if pg1 > pg2:
        short = hd1
        long = hd2
    else:
        short = hd2
        long = hd1

    return 1 if ( short.close[offset] > short.close[offset-n] ) and ( long.close[offset-n] > long.close[offset] ) else 0