def strategy_to_json(self, ExtraDayReturnSquareMeta):
     data_json = {}
     try:
         signal_finder = SignalFinder()
         is_error = False
         for member in ExtraDayReturnSquareMeta.get_const_member_list():
             member_value = getattr(ExtraDayReturnSquareMeta, member)
             if member in ExtraDayReturnSquareMeta.get_bool_list():
                 data_json[member] = is_bool(
                     getattr(ExtraDayReturnSquareMeta, member))
             elif member in ExtraDayReturnSquareMeta.get_signal_list():
                 data_json[member] = (
                     signal_finder.get_signal_id_by_name(member_value),
                     member_value)[isinstance(member_value, int)]
                 if data_json[member] == -1:
                     is_error = True
             else:
                 data_json[member] = getattr(ExtraDayReturnSquareMeta,
                                             member)
         if not is_error:
             signal_object = SignalObject()
             signal_object.name = ExtraDayReturnSquareMeta.Name
             signal_object.type = ExtraDayReturnSquareMeta.Type
             signal_object.enable = True
             signal_object.node = json.dumps(data_json)
             self.__signal_object_list.append(signal_object)
     except Exception as e:
         raise CSVConverterError(ExtraDayReturnSquareMeta.Name,
                                 ExtraDayReturnSquareMeta.Type, e.message)
 def strategy_to_json(self, TradingUniverseMeta):
     data_json = {}
     try:
         signal_finder = SignalFinder()
         is_error = False
         for member in TradingUniverseMeta.get_const_member_list():
             member_value = getattr(TradingUniverseMeta, member)
             if member in TradingUniverseMeta.get_bool_list():
                 data_json[member] = is_bool(
                     getattr(TradingUniverseMeta, member))
             elif member in TradingUniverseMeta.get_signal_list():
                 data_json[member] = (
                     signal_finder.get_signal_id_by_name(member_value),
                     member_value)[isinstance(member_value, int)]
                 if data_json[member] == -1:
                     is_error = True
             else:
                 data_json[member] = getattr(TradingUniverseMeta, member)
         data_json["TradingUniverse"] = reference_arg_manager(
             "$GetTradingUniverse({0})".format(None))
         if not is_error:
             signal_object = SignalObject()
             signal_object.name = TradingUniverseMeta.Name
             signal_object.type = TradingUniverseMeta.Type
             signal_object.enable = True
             signal_object.node = json.dumps(data_json)
             self.__signal_object_list.append(signal_object)
     except Exception as e:
         raise CSVConverterError(TradingUniverseMeta.Name,
                                 TradingUniverseMeta.Type, e.message)
Example #3
0
 def strategy_to_json(self, SouthMeta):
     data_json = {}
     try:
         signal_finder = SignalFinder()
         is_error = False
         for member in SouthMeta.get_const_member_list():
             member_value = getattr(SouthMeta, member)
             if member in SouthMeta.get_bool_list():
                 data_json[member] = is_bool(getattr(SouthMeta, member))
             elif member in SouthMeta.get_signal_list():
                 data_json[member] = (signal_finder.get_signal_id_by_name(member_value), member_value)[isinstance(member_value, int)]
                 if data_json[member] == -1:
                     is_error=True
             else:
                 data_json[member] = getattr(SouthMeta, member)
         param = data_json["South"].strip().split('$')
         param = param[1].split(',')
         param[0] = param[0][1:]
         param[-1] = param[-1][:-1]
         data_json["South"] = reference_arg_manager("$GetSouth({0},{1})".format(SouthMeta.BalanceDate,param[-1]))
         param = data_json["South1"].strip().split('$')
         param = param[1].split(',')
         param[0] = param[0][1:]
         param[-1] = param[-1][:-1]
         data_json["South1"] = reference_arg_manager("$GetSouth({0},{1})".format(SouthMeta.BalanceDate,param[-1]))
         if not is_error:
             signal_object = SignalObject()
             signal_object.name = SouthMeta.Name
             signal_object.type = SouthMeta.Type
             signal_object.enable = True
             signal_object.node = json.dumps(data_json)
             self.__signal_object_list.append(signal_object)
     except Exception as e:
         raise CSVConverterError(SouthMeta.Name, SouthMeta.Type, e.message)
 def strategy_to_json(self, SectorAmountDiversificationMeta):
     data_json = {}
     try:
         signal_finder = SignalFinder()
         is_error = False
         for member in SectorAmountDiversificationMeta.get_const_member_list():
             member_value = getattr(SectorAmountDiversificationMeta, member)
             if member in SectorAmountDiversificationMeta.get_bool_list():
                 data_json[member] = is_bool(getattr(SectorAmountDiversificationMeta, member))
             elif member in SectorAmountDiversificationMeta.get_signal_list():
                 data_json[member] = (signal_finder.get_signal_id_by_name(member_value), member_value)[isinstance(member_value, int)]
                 if data_json[member] == -1:
                     is_error=True
             else:
                 data_json[member] = getattr(SectorAmountDiversificationMeta, member)
         data_json["SectorAmountDiversification"] = reference_arg_manager("$GetSectorAmountDiversification({0},{1},{2})".format(SectorAmountDiversificationMeta.CalculateDate,SectorAmountDiversificationMeta.SegmentDays,SectorAmountDiversificationMeta.MAWin))
         if not is_error:
             signal_object = SignalObject()
             signal_object.name = SectorAmountDiversificationMeta.Name
             signal_object.type = SectorAmountDiversificationMeta.Type
             signal_object.enable = True
             signal_object.node = json.dumps(data_json)
             self.__signal_object_list.append(signal_object)
     except Exception as e:
         raise CSVConverterError(SectorAmountDiversificationMeta.Name, SectorAmountDiversificationMeta.Type, e.message)
Example #5
0
 def strategy_to_json(self, SouthMeta):
     data_json = {}
     try:
         signal_finder = SignalFinder()
         is_error = False
         for member in SouthMeta.get_const_member_list():
             member_value = getattr(SouthMeta, member)
             if member in SouthMeta.get_bool_list():
                 data_json[member] = is_bool(getattr(SouthMeta, member))
             elif member in SouthMeta.get_signal_list():
                 data_json[member] = (
                     signal_finder.get_signal_id_by_name(member_value),
                     member_value)[isinstance(member_value, int)]
                 if data_json[member] == -1:
                     is_error = True
             else:
                 data_json[member] = getattr(SouthMeta, member)
         param = data_json["South"].strip().split('$')
         param = param[1].split(',')
         param[0] = param[0][1:]
         param[-1] = param[-1][:-1]
         data_json["South"] = reference_arg_manager(
             "$GetSouth({0},{1})".format(SouthMeta.BalanceDate, param[-1]))
         param = data_json["South1"].strip().split('$')
         param = param[1].split(',')
         param[0] = param[0][1:]
         param[-1] = param[-1][:-1]
         data_json["South1"] = reference_arg_manager(
             "$GetSouth({0},{1})".format(SouthMeta.BalanceDate, param[-1]))
         if not is_error:
             signal_object = SignalObject()
             signal_object.name = SouthMeta.Name
             signal_object.type = SouthMeta.Type
             signal_object.enable = True
             signal_object.node = json.dumps(data_json)
             self.__signal_object_list.append(signal_object)
     except Exception as e:
         raise CSVConverterError(SouthMeta.Name, SouthMeta.Type, e.message)
 def strategy_to_json(self, SectorAmountDiversificationMeta):
     data_json = {}
     try:
         signal_finder = SignalFinder()
         is_error = False
         for member in SectorAmountDiversificationMeta.get_const_member_list(
         ):
             member_value = getattr(SectorAmountDiversificationMeta, member)
             if member in SectorAmountDiversificationMeta.get_bool_list():
                 data_json[member] = is_bool(
                     getattr(SectorAmountDiversificationMeta, member))
             elif member in SectorAmountDiversificationMeta.get_signal_list(
             ):
                 data_json[member] = (
                     signal_finder.get_signal_id_by_name(member_value),
                     member_value)[isinstance(member_value, int)]
                 if data_json[member] == -1:
                     is_error = True
             else:
                 data_json[member] = getattr(
                     SectorAmountDiversificationMeta, member)
         data_json["SectorAmountDiversification"] = reference_arg_manager(
             "$GetSectorAmountDiversification({0},{1},{2})".format(
                 SectorAmountDiversificationMeta.CalculateDate,
                 SectorAmountDiversificationMeta.SegmentDays,
                 SectorAmountDiversificationMeta.MAWin))
         if not is_error:
             signal_object = SignalObject()
             signal_object.name = SectorAmountDiversificationMeta.Name
             signal_object.type = SectorAmountDiversificationMeta.Type
             signal_object.enable = True
             signal_object.node = json.dumps(data_json)
             self.__signal_object_list.append(signal_object)
     except Exception as e:
         raise CSVConverterError(SectorAmountDiversificationMeta.Name,
                                 SectorAmountDiversificationMeta.Type,
                                 e.message)
Example #7
0
 def strategy_to_json(self, JinMeta):
     data_json = {}
     try:
         signal_finder = SignalFinder()
         is_error = False
         for member in JinMeta.get_const_member_list():
             member_value = getattr(JinMeta, member)
             if member in JinMeta.get_bool_list():
                 data_json[member] = is_bool(getattr(JinMeta, member))
             elif member in JinMeta.get_signal_list():
                 data_json[member] = (signal_finder.get_signal_id_by_name(member_value), member_value)[isinstance(member_value, int)]
                 if data_json[member] == -1:
                     is_error=True
             else:
                 data_json[member] = getattr(JinMeta, member)
         if not is_error:
             signal_object = SignalObject()
             signal_object.name = JinMeta.Name
             signal_object.type = JinMeta.Type
             signal_object.enable = True
             signal_object.node = json.dumps(data_json)
             self.__signal_object_list.append(signal_object)
     except Exception as e:
         raise CSVConverterError(JinMeta.Name, JinMeta.Type, e.message)