예제 #1
0
def signal_function(px, params):
    """
        The main trading logic goes here, called by generate_signals above
    """
    ind2 = ema(px, params['SMA_period_short'])
    ind3 = ema(px, params['SMA_period_long'])

    if ind2 - ind3 > 0:
        return -1
    elif ind2 - ind3 < 0:
        return 1
    else:
        return 0
def signal_function(px, params):
    """
        The main trading logic goes here, called by generate_signals above
    """
    upper, mid, lower = bollinger_band(px, params['BBands_period'])
    ind2 = ema(px, params['SMA_period_short'])
    ind3 = ema(px, params['SMA_period_long'])
    last_px = px[-1]
    dist_to_upper = 100 * (upper - last_px) / (upper - lower)

    if dist_to_upper > 95:
        return -1
    elif dist_to_upper < 5:
        return 1
    elif dist_to_upper > 40 and dist_to_upper < 60 and ind2 - ind3 < 0:
        return -1
    elif dist_to_upper > 40 and dist_to_upper < 60 and ind2 - ind3 > 0:
        return 1
    else:
        return 0