Esempio n. 1
0
 def add_indicators(self):
     self.candles = self.candles.drop(['Open_time', 'Close_time'], axis=1)
     self.candles['EMA - 15'] = ema(self.candles['Close'].tolist(), 15)
     self.candles['aaron down'] = aroon_down(self.candles['Close'].tolist(), 25)
     self.candles['aaron up'] = aroon_up(self.candles['Close'].tolist(), 25)
     self.candles['tenkansen'] = tenkansen(self.candles['Close'].tolist())
     self.candles['kijunsen'] = kijunsen(self.candles['Close'].tolist())
     self.candles['momentun'] = momentum(self.candles['Close'], 15)
     return self.candles
Esempio n. 2
0
 def test_aroon_up_invalid_period(self):
     period = 128
     with self.assertRaises(Exception) as cm:
         aroon.aroon_up(self.data, period)
     expected = "Error: data_len < period"
     self.assertEqual(str(cm.exception), expected)
Esempio n. 3
0
 def test_aroon_up(self):
     period = 25
     aroon_up = aroon.aroon_up(self.data, period)
     np.testing.assert_array_equal(aroon_up, self.aroon_up_expected)
Esempio n. 4
0
 def get_analysis(self, data):
     if self.params['aroon_direction'] == 'up':
         return aroon_up(data, self.params['period'])[-1]
     return aroon_down(data, self.params['period'])[-1]
Esempio n. 5
0
def aroon(data):
    """
    Function return result
    """
    quotes = {}
    # xdate = quotes['timestamp']=numpy.asarray([item[0] for item in data])
    quotes['open'] = numpy.asarray([item[1] for item in data])
    quotes['high'] = numpy.asarray([item[2] for item in data])
    quotes['low'] = numpy.asarray([item[3] for item in data])
    quotes['close'] = numpy.asarray([item[4] for item in data])
    open = quotes['open']
    open = open[0]
    close = quotes['close']
    close = close[0]
    high = quotes['high']
    high = high[::-1]
    #print(high)
    low = quotes['low']
    low = low[::-1]
    #print(low)

    #    * Logic

    # print(aroon_up(high,7))
    # print(aroon_down(low,7))

    aroon = aroon_up(high, 7) - aroon_down(low, 7)
    # print(aroon[-1])

    # bar = close > open ? 1 : close < open ? -1 : 0
    bar = None

    # // Свеча зеленая
    if (close > open):
        bar = "green"
        print(f'Close: {close} > Open: {open}')
        print("Bar: ", bar)

    #   // Свеча красная
    elif (close < open):
        bar = "red"
        print(f"Close: {close} < Open: {open}")
        print("Bar: ", bar)

    #   // Ничего не произошло
    else:
        bar = "still"
        print(f'Close: {close} = Open: {open}')
        print("Bar: ", bar)

    #    * Signals
    aroon_int = aroon[-1]
    print(f"Aroon: {aroon_int}")
    up = None
    if aroon_int > 80 and bar == "red":
        up = True
        print(f"Aroon: {aroon_int}, Up = true")

    down = None
    if aroon_int < -80 and bar == "green":
        down = True
        print(f"Aroon: {aroon_int}, Down = true")

    if up:
        return 'up'
    elif down:
        return 'down'
    else:
        return 'hold'