Example #1
0
 def testPLUS_DI(self):
     barDs = self.__loadBarDS()
     self.assertTrue(compare(
         indicator.PLUS_DI(barDs, 252, 14)[14], 20.3781))
     self.assertTrue(
         compare(indicator.PLUS_DI(barDs, 252, 14)[14 + 13], 22.1073))
     self.assertTrue(
         compare(indicator.PLUS_DI(barDs, 252, 14)[14 + 14], 20.3746))
     self.assertTrue(compare(
         indicator.PLUS_DI(barDs, 252, 14)[-1], 21.0000))
 def testPLUS_DI(self):
     barDs = self.__loadBarDS()
     self.assertAmountsAreEqual(
         indicator.PLUS_DI(barDs, 252, 14)[14], 20.3781)
     self.assertAmountsAreEqual(
         indicator.PLUS_DI(barDs, 252, 14)[14 + 13], 22.1073)
     self.assertAmountsAreEqual(
         indicator.PLUS_DI(barDs, 252, 14)[14 + 14], 20.3746)
     self.assertAmountsAreEqual(
         indicator.PLUS_DI(barDs, 252, 14)[-1], 21.0000)
Example #3
0
    def checkAdx(self,bars):
        signal = 0
        self.__adx = indicator.AROON(self.__feed[self.__instrument],len(self.__feed[self.__instrument]),14)
        self.plus_di = indicator.PLUS_DI(self.__feed[self.__instrument],len(self.__feed[self.__instrument]),14)
        self.minus_di = indicator.MINUS_DI(self.__feed[self.__instrument], len(self.__feed[self.__instrument]), 14)
        if self.__adx is None or self.__macd is None or len(self.__macd) < 2:  # to check the first item is Nan
            return signal
        print self.__macd[-2]
        if self.__macd[-2]<0 and self.__macd[-1]>0 and self.__adx[-1] > self.__adx[-2] \
                and self.plus_di[-1] > self.minus_di[-1]:
            signal = 1
        elif self.__macd[-2]>0 and self.__macd[-1]<0 and self.__adx[-1] < self.__adx[-2] \
                and self.plus_di[-1] < self.minus_di[-1]:
            signal = -1

        return signal