Esempio n. 1
0
    def onRspQryInvestorPosition(self, data, error, n, last):
        """持仓查询回报"""
        if error['ErrorID'] == 0:
            _data   = utf_dict(data)
            _dir    = _data['PosiDirection']
            _date   = _data['PositionDate']
            _vol    = _data['Position']
            _symbol = _data['InstrumentID']
            
            if _symbol not in self.dictPosition:
                self.dictPosition[_symbol] = {}
            self.dictPosition[_symbol][(_dir,_date)] = _vol

            if last:
                def sent_position(ee,dict_):
                    for symbol,_dict in dict_.items():
                        event = Event(type_=EVENT_POSITION)
                        event.symbol = symbol
                        _dict['InstrumentID'] = symbol
                        event.dict_['data'] = _dict
                        ee.put(event)
                
                _dict = copy(self.dictPosition)
                th_fork(sent_position,(self.__eventEngine,_dict))
                self.dictPosition = {}
        else:
            event = Event(type_=EVENT_LOG)
            log = u'持仓查询回报,错误代码:' + unicode(error['ErrorID']) + u',' + u'错误信息:' + error['ErrorMsg'].decode('gbk')
            event.dict_['log'] = log
            self.__eventEngine.put(event)
Esempio n. 2
0
    def __process(self, event):
        """处理事件"""
        # 检查是否存在对该事件进行监听的处理函数
        if event.type_ in self.__handlers:
            #若存在,则按顺序将事件传递给处理函数执行
            [handler(event) for handler in self.__handlers[event.type_]]

            if event.repeat > 0:
                th_fork(self.repeatEvent, (event, ))
Esempio n. 3
0
    def __process(self, event):
        """处理事件"""
        # 检查是否存在对该事件进行监听的处理函数
        if event.type_ in self.__handlers:
            #若存在,则按顺序将事件传递给处理函数执行
            [handler(event) for handler in self.__handlers[event.type_]]

            if event.repeat>0:
                th_fork(self.repeatEvent,(event,))
 def __process(self, event):
     """处理事件"""
     # 检查是否存在对该事件进行监听的处理函数
     if event.type_ in self.__handlers:
         #若存在,则按顺序将事件传递给处理函数执行
         for _h in self.__handlers[event.type_]:
         
             if self.__handlers_sync[_h]:
                 _h(event)
             else:
                 th_fork(_h,(event,))
Esempio n. 5
0
 def __process(self, event):
     """处理事件"""
     # 检查是否存在对该事件进行监听的处理函数
     if event.type_ in self.__handlers:
         #若存在,则按顺序将事件传递给处理函数执行
         for _h in self.__handlers[event.type_]:
         
             if self.__handlers_sync[_h]:
                 _h(event)
             else:
                 th_fork(_h,(event,))