def write_log(self, msg: str): """""" event = Event(EVENT_LOG) log = LogData(msg=msg, gateway_name='IB') event.data = log self.event_engine.put(event)
def write_log(self, msg: str, algo: AlgoTemplate = None): """""" if algo: msg = f"{algo.algo_name}:{msg}" event = Event(EVENT_ALGO_LOG) event.data = msg self.event_engine.put(event)
def put_variables_event(self, algo: AlgoTemplate, variables: dict): """""" event = Event(EVENT_ALGO_VARIABLES) event.data = { "algo_name": algo.algo_name, "variables": variables } self.event_engine.put(event)
def put_parameters_event(self, algo: AlgoTemplate, parameters: dict): """""" event = Event(EVENT_ALGO_PARAMETERS) event.data = { "algo_name": algo.algo_name, "parameters": parameters } self.event_engine.put(event)
def put_setting_event(self, setting_name: str, setting: dict): """""" event = Event(EVENT_ALGO_SETTING) event.data = { "setting_name": setting_name, "setting": setting } self.event_engine.put(event)
def write_log(self, msg: str, algo: str = None): """""" if algo: msg = f"{algo}:{msg}" event = Event(EVENT_ALGO_LOG) event.data = msg self.event_engine.put(event)
def write_log(self, msg: str): """ 写回测日志 :param msg: :return: """ event = Event(EVENT_BACKTESTER_LOG) event.data = msg self.event_engine.put(event)
def main(): event_engine = EventEngine() event_engine.register("test", handle) event_engine.start() evt = Event("test") evt.data = "df" print("recei22:" + evt.__str__()) event_engine.put(evt) sleep(1) event_engine.stop()
def remove_algo_setting(self, setting_name: str): """""" if setting_name not in self.algo_settings: return self.algo_settings.pop(setting_name) event = Event(EVENT_ALGO_SETTING) event.data = {"setting_name": setting_name, "setting": None} self.event_engine.put(event) self.save_algo_setting()