Beispiel #1
0
def historicalDirection():
    """
	Prevent: Scenario where sells at local minimum & then price immediately starts going up
	By: If price from one minute ago is lower than price from 5 minutes ago, do not trade.
	This function returns 'DOWN' if this is the case.
	"""
    if not USE_HISTORICAL_DIRECTION:
        return 'OFF'
    p = [float(d['close']) for d in bin.klines(currency, '1m')[-6:-1]]
    direction = sgn(p[-1] - p[-5] - 0.00000002)
    return direction
Beispiel #2
0
def getDirection():
	p = [float(d['close']) for d in bin.klines(currency, '1m')[-5:-1]]
	direction = sgn(p[-1]-p[-2])
	direction2 = sgn(p[-2]-p[-3])
	if direction == direction2:
		return direction
	elif (direction == 'UP' and direction2 == 'FLAT') or (direction2 == 'UP' and direction == 'FLAT'):
		return 'UP'
	elif (direction == 'DOWN' and direction == 'FLAT') or (direction2 == 'DOWN' and direction == 'FLAT'):
		return 'DOWN'
	else:
		return 'FLAT'
Beispiel #3
0
def instantPriceDirection():
    instantPrice = float(getPrice(currency))
    p = [float(d['close']) for d in bin.klines(currency, '1m')[-6:-1]]
    oneMinuteAgoClosingPrice = p[-1]
    direction = sgn(instantPrice - oneMinuteAgoClosingPrice + 0.00000002)
    return direction
Beispiel #4
0
def sellAtLocalMaximum():
    p = [float(d['close']) for d in bin.klines(currency, '1m')[-35:-3]]
    currentP, pastH = getPrice(currency), deci(max(p))
    return float(currentP) - 0.00000003 > float(pastH), currentP, pastH