def onPosition(self, position): """持仓信息推送""" # 通用事件 event1 = Event(type_=EVENT_POSITION) event1.dict_['data'] = position self.eventEngine.put(event1) pass
def onTick(self, tick): """市场行情推送""" # 通用事件 event1 = Event(type_=EVENT_TICK) event1.dict_['data'] = tick self.eventEngine.put(event1) pass
def onOrder(self, order): """订单变化推送""" # 通用事件 event1 = Event(type_=EVENT_ORDER) event1.dict_['data'] = order self.eventEngine.put(event1) pass
def onContract(self, contract): """合约基础信息推送""" # 通用事件 event1 = Event(type_=EVENT_CONTRACT) event1.dict_['data'] = contract self.eventEngine.put(event1) pass
def onLog(self, log): """日志推送""" # 通用事件 event1 = Event(type_=EVENT_LOG) event1.dict_['data'] = log self.eventEngine.put(event1) pass
def onError(self, error): """错误信息推送""" # 通用事件 event1 = Event(type_=EVENT_ERROR) event1.dict_['data'] = error self.eventEngine.put(event1) pass
def __runTimer(self): """运行在计时器线程中的循环函数""" while self.__timerActive: # 创建计时器事件 event = Event(type_=EVENT_TIMER) # 向队列中存入计时器事件 self.put(event) # 等待 sleep(self.__timerSleep)
def onAccount(self, account): """账户信息推送""" # 通用事件 event1 = Event(type_=EVENT_ACCOUNT) event1.dict_['data'] = account self.eventEngine.put(event1)
def onTrade(self, trade): """成交信息推送""" # 通用事件 event1 = Event(type_=EVENT_TRADE) event1.dict_['data'] = trade pass