Exemple #1
0
    def execute(self, sliding_window):
        points_to_process = list(
            filter(lambda item: 2 * item + 1 <= len(sliding_window),
                   self.interval_points))
        logging.info("interval points to process: {points_to_process}".format(
            points_to_process=points_to_process))

        if len(points_to_process) == 0:
            return None

        points = point_extractor.extract_points(sliding_window,
                                                points_to_process)
        logging.info("extracted points for each interval: {points}".format(
            points=points))
        for point in points:
            threshold = self.threshold[point] if isinstance(
                self.threshold, collections.Mapping) else self.threshold
            if analyzer.is_local_max(points[point], threshold):
                logging.info(
                    "point {point} of domain {domain} is local max".format(
                        point=points[point], domain=point))
                return 'SELL'
            elif analyzer.is_local_min(points[point], threshold):
                logging.info(
                    "point {point} of domain {domain} is local min".format(
                        point=points[point], domain=point))
                return 'BUY'
        return None
Exemple #2
0
 def test_local_max_stable_no_thres(self):
     point = {'left': 1.32, 'mid': 1.32, 'right': 1.32}
     self.assertTrue(analyzer.is_local_max(point, 0) == False, "point {point} is no local max".format(point = point))
Exemple #3
0
 def test_local_max_thres(self):
     point = {'left': 1.32, 'mid': 1.3333, 'right': 1.30}
     threshold = 0.01
     self.assertTrue(analyzer.is_local_max(point, threshold) == True, "point {point} is local max with threshold {threshold}".format(point = point, threshold = threshold))
Exemple #4
0
 def test_local_max_no_thres(self):
     point = {'left': 1.32, 'mid': 1.33, 'right': 1.30}
     self.assertTrue(analyzer.is_local_max(point, 0) == True, "point {point} is local max".format(point = point))