def clockhandel(self, Event): date = Event.data.strftime("%Y-%m-%d") bar = tusharebar(date).getOneBar("600008.SH") event = Event(event_type=self.EventType, data=bar) print("传递bar") print(bar) self.event_engine.put(event)
def push_quotation(self): while self.is_active: clock_data = self.fetch_clock() date = clock_data.data.strftime("%Y-%m-%d") bar = tusharebar(date).getOneBar("600008.SH") event = Event(event_type=self.EventType, data=bar) print("传递bar") print(bar) self.event_engine.put(event)
def push_quotation(self): while self.is_active: try: clock_data = self.fetch_clock() except: self.wait() continue feed_data = self.clockhandel(clock_data) event = Event(event_type=self.EventType, data=feed_data) self.event_engine.put(event) self.wait()
def _active_run(self): """ 轮询事件是否触发 :return: """ while self.is_active: for _, config in self.__configs.iteritems(): params = config.is_active() if params: event = Event(type=config.event_type, params=params) self.__event_engine.put(event)
def create_algo_instance(self, event_type, param_dict): self._event_engine.put(event=Event(event_type, params=param_dict))
def push_clock_event(self, data): event = Event(event_type=self.EventType, data=data) self.event_engine.put(event)
def __init__(self, market, context, bar_data): self.data = market self.context = context Event.__init__(self)
def push_event_type(self, clock_handler): event = Event(eventType=self.EventType, data=Clock(self.trading_state, clock_handler.clock_type)) for engine in self.eventEngine: engine.put(event)