def __init_by_pattern_id__(self, pattern_id_str: str): # Example: 1_1_1_AAPL_12_2015-12-03_00:00_2016-01-07_00:00 parts = pattern_id_str.split('_') self.equity_type_id = int(parts[0]) self.period_id = int(parts[1]) self.period = PRD.get_period(self.period_id) self.aggregation = int(parts[2]) self.ticker_id = parts[3] self.pattern_type_id = int(parts[4]) self.pattern_type = FT.get_pattern_type(self.pattern_type_id) self.range_start_date_str = parts[5] self.range_start_time_str = parts[6] self.range_end_date_str = parts[7] self.range_end_time_str = parts[8] self.date_start = MyDate.get_datetime_object(self.range_start_date_str) self.date_end = MyDate.get_datetime_object(self.range_end_date_str) self.range_length = (self.date_end - self.date_start).days self.range_id = '{}_{}_{}_{}'.format(self.range_start_date_str, self.range_start_time_str, self.range_end_date_str, self.range_end_time_str) self.ts_from = MyDate.get_epoch_seconds_from_datetime(parts[5]) self.ts_to = MyDate.get_epoch_seconds_from_datetime(parts[7]) self.range_length_days = int( (self.ts_to - self.ts_from) / (60 * 60 * 24)) self.and_clause = self.__get_search_and_clause__()
def pattern_type(self): return FT.get_pattern_type(int(self._id_components[4]))