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_min_thres(self):
     point = {'left': 1.355, 'mid': 1.31, 'right': 1.33}
     threshold = 0.01
     self.assertTrue(analyzer.is_local_min(point, threshold) == True, "point {point} is local min with threshold {threshold}".format(point = point, threshold = threshold))
Exemple #3
0
 def test_local_min_desc_thres(self):
     point = {'left': 1.32, 'mid': 1.31, 'right': 1.30}
     threshold = 0.01
     self.assertTrue(analyzer.is_local_min(point, threshold) == False, "point {point} is no local min with threshold {threshold}".format(point = point, threshold = threshold))
Exemple #4
0
 def test_local_min_no_thres(self):
     point = {'left': 1.32, 'mid': 1.30, 'right': 1.31}
     self.assertTrue(analyzer.is_local_min(point, 0) == True, "point {point} is local min".format(point = point))
Exemple #5
0
 def test_local_min_asc_no_thres(self):
     point = {'left': 1.32, 'mid': 1.33, 'right': 1.35}
     self.assertTrue(analyzer.is_local_min(point, 0) == False, "point {point} is no local min".format(point = point))