def __old_init__(self, equity_type_id: int, period: str, aggregation: int, ticker_id: str, pattern_type: str, pattern_range_id: str): self.equity_type_id = equity_type_id self.period_id = PRD.get_id(period) self.aggregation = aggregation self.ticker_id = ticker_id self.pattern_type_id = FT.get_id(pattern_type) self.range_id = pattern_range_id self.__init_by_pattern_id__(self.id)
def __init__(self, **kwargs): if 'pattern_id' in kwargs: self.__init_by_pattern_id__(kwargs['pattern_id']) else: self.equity_type_id = kwargs['equity_type_id'] self.period_id = PRD.get_id(kwargs['_period']) self.aggregation = kwargs['_aggregation'] self.ticker_id = kwargs['ticker_id'] self.pattern_type_id = FT.get_id(kwargs['pattern_type']) self.range_id = kwargs['pattern_range_id'] self.__init_by_pattern_id__(self.id)
def set_trade_id_as_pattern_id_to_find(self, trade_id: str): # From: Breakout-Expected_win-Limit_fix-mean04_DAILY_PG_Channel_2017-10-25_00:00_2017-11-07_00:00 # To: 1_1_1_KO_22_2016-07-22_00:00_2016-09-28_00:00 # return '{}-{}-{}-{}_{}'.format( # self.buy_trigger, self.trade_box_type, self.trade_strategy, mean_aggregation, self.pattern.id_readable) # def __get_pattern_id__(self) -> PatternID: # kwargs = { # 'equity_type_id': self.data_dict_obj.get(DC.EQUITY_TYPE_ID), # '_period': self.data_dict_obj.get(DC.PERIOD), # '_aggregation': self.data_dict_obj.get(DC.PROCESS), # 'ticker_id': self.ticker_id, # 'pattern_type': self.pattern_type, # 'pattern_range_id': self.pattern_range.id # } # return PatternID(**kwargs) # [0]: Breakout - Expected_ # [1]: win - Limit_ # [2]: fix - mean04_ # [3]: DAILY_ # [4]: PG_ # [5]: Channel_ # [6]: 2017 - 10 - 25 # _ # [7]: 00:00 # _ # [8]: 2017 - 11 - 07 # _ # [9]: 00:00 # # Breakout - Expected_win - Trailing_stepped_stop - mean04_DAILY_LTCUSD_Channel_2016 - 12 - 0 # 9_00: 00_2016 - 12 - 17_00:00 # '10-10-30-DAILY-0-Channel-2016-12-09-00:00-2016-12-17' trade_id_parts_01 = trade_id.split('-') trade_id_parts_02 = trade_id.split('_') buy_trigger_id = BT.get_id(trade_id_parts_01[0]) trade_box_type_id = BTT.get_id(trade_id_parts_01[1]) trade_strategy_id = TSTR.get_id(trade_id_parts_01[2]) symbol = trade_id_parts_02[4] pattern_type_id = FT.get_id(trade_id_parts_02[5]) date_from = trade_id_parts_02[6] time_from = trade_id_parts_02[7] date_to = trade_id_parts_02[8] time_to = trade_id_parts_02[9] pattern_id = '-'.join([str(buy_trigger_id), str(trade_box_type_id), str(trade_strategy_id), symbol, str(pattern_type_id), date_from, time_from, date_to, time_to]) self.pattern_ids_to_find = [pattern_id]