當前位置: 首頁>>代碼示例>>Python>>正文


Python EventEngine.stop方法代碼示例

本文整理匯總了Python中eventEngine.EventEngine.stop方法的典型用法代碼示例。如果您正苦於以下問題:Python EventEngine.stop方法的具體用法?Python EventEngine.stop怎麽用?Python EventEngine.stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eventEngine.EventEngine的用法示例。


在下文中一共展示了EventEngine.stop方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from eventEngine import EventEngine [as 別名]
# 或者: from eventEngine.EventEngine import stop [as 別名]

#.........這裏部分代碼省略.........
        """撤單"""
        self.td.cancelOrder(instrumentid, exchangeid, orderref, frontid, sessionid)
        
    #----------------------------------------------------------------------
    def getAccountPosition(self, event):
        """循環查詢賬戶和持倉"""
        self.countGet = self.countGet + 1
        
        # 每1秒發一次查詢
        if self.countGet >= 20:
            self.countGet = 0
            if self.lastGet == 'Account':
                self.getPosition()
                self.lastGet = 'Position'
            else:
                self.lastGet = 'Account'
                self.getAccount()
    #----------------------------------------------------------------------
    def initGet(self, event):
        """在交易服務器登錄成功後,開始初始化查詢"""
        # 打開設定文件setting.vn
        f = shelve.open('setting.vn')
        
        # 嘗試讀取設定字典,若該字典不存在,則發出查詢請求
        try:
            d = f['instrument']
            
            # 如果本地保存的合約數據是今日的,則載入,否則發出查詢請求
            today = date.today()
            if d['date'] == today:
                self.dictInstrument = d['dictInstrument']
                
                event = Event(type_=EVENT_LOG)
                log = u'合約信息讀取完成'
                event.dict_['log'] = log
                self.ee.put(event)            
    
                self.getInvestor()
                
                # 開始循環查詢
                self.ee.register(EVENT_TIMER, self.getAccountPosition)                 
            else:
                self.getInstrument()
        except KeyError:
            self.getInstrument()
            
        f.close()
#        _exchangeid = self.dictInstrument[self.symbol]['ExchangeID']
        self.exchangeid = ""#_exchangeid
        self.subscribe(self.symbol,self.exchangeid)
    #----------------------------------------------------------------------
    def insertInstrument(self, event):
        """插入合約對象"""
        data = event.dict_['data']
        last = event.dict_['last']
        
        self.dictInstrument[data['InstrumentID']] = data
        
        # 合約對象查詢完成後,查詢投資者信息並開始循環查詢
        if last:
            # 將查詢完成的合約信息保存到本地文件,今日登錄可直接使用不再查詢
            self.saveInstrument()
            
            event = Event(type_=EVENT_LOG)
            log = u'合約信息查詢完成'
            event.dict_['log'] = log
            self.ee.put(event)            

            self.getInvestor()
            # 開始循環查詢
            self.ee.register(EVENT_TIMER, self.getAccountPosition)              
        
    #----------------------------------------------------------------------
    def selectInstrument(self, instrumentid):
        """獲取合約信息對象"""
        try:
            instrument = self.dictInstrument[instrumentid]
        except KeyError:
            instrument = None
        return instrument
    
    #----------------------------------------------------------------------
    def exit(self):
        """退出"""
        # 銷毀API對象
        self.td = None
        self.md = None
        
        # 停止事件驅動引擎
        self.ee.stop()
        
    #----------------------------------------------------------------------
    def saveInstrument(self):
        """保存合約屬性數據"""
        f = shelve.open('setting.vn')
        d = {}
        d['dictInstrument'] = self.dictInstrument
        d['date'] = date.today()
        f['instrument'] = d
        f.close()
開發者ID:lukesummer,項目名稱:ctp,代碼行數:104,代碼來源:demoEngine.py

示例2: __init__

# 需要導入模塊: from eventEngine import EventEngine [as 別名]
# 或者: from eventEngine.EventEngine import stop [as 別名]

#.........這裏部分代碼省略.........
        self.td.cancelOrder(instrumentid, exchangeid, orderref, frontid, sessionid)
        
    #----------------------------------------------------------------------
    def getAccountPosition(self, event):
        """循環查詢賬戶和持倉"""
        self.countGet = self.countGet + 1
        
        # 每5秒發一次查詢
        if self.countGet > 5:
            self.countGet = 0   # 清空計數
            
            if self.lastGet == 'Account':
                self.getPosition()
                self.lastGet = 'Position'
            else:
                self.getAccount()
                self.lastGet = 'Account'
    
    #----------------------------------------------------------------------
    def initGet(self, event):
        """在交易服務器登錄成功後,開始初始化查詢"""
        # 打開設定文件setting.vn
        f = shelve.open('setting.vn')
        
        # 嘗試讀取設定字典,若該字典不存在,則發出查詢請求
        try:
            d = f['instrument']
            
            # 如果本地保存的合約數據是今日的,則載入,否則發出查詢請求
            today = date.today()
            if d['date'] == today:
                self.dictInstrument = d['dictInstrument']
                
                event = Event(type_=EVENT_LOG)
                log = u'合約信息讀取完成'
                event.dict_['log'] = log
                self.ee.put(event)            
    
                self.getInvestor()
                
                # 開始循環查詢
                self.ee.register(EVENT_TIMER, self.getAccountPosition)                 
            else:
                self.getInstrument()
        except KeyError:
            self.getInstrument()
            
        f.close()
 
    #----------------------------------------------------------------------
    def insertInstrument(self, event):
        """插入合約對象"""
        data = event.dict_['data']
        last = event.dict_['last']
        
        self.dictInstrument[data['InstrumentID']] = data
        
        # 合約對象查詢完成後,查詢投資者信息並開始循環查詢
        if last:
            # 將查詢完成的合約信息保存到本地文件,今日登錄可直接使用不再查詢
            self.saveInstrument()
            
            event = Event(type_=EVENT_LOG)
            log = u'合約信息查詢完成'
            event.dict_['log'] = log
            self.ee.put(event)            

            self.getInvestor()
            
            # 開始循環查詢
            self.ee.register(EVENT_TIMER, self.getAccountPosition)              
        
    #----------------------------------------------------------------------
    def selectInstrument(self, instrumentid):
        """獲取合約信息對象"""
        try:
            instrument = self.dictInstrument[instrumentid]
        except KeyError:
            instrument = None
        return instrument
    
    #----------------------------------------------------------------------
    def exit(self):
        """退出"""
        # 銷毀API對象
        self.td = None
        self.md = None
        
        # 停止事件驅動引擎
        self.ee.stop()
        
    #----------------------------------------------------------------------
    def saveInstrument(self):
        """保存合約屬性數據"""
        f = shelve.open('setting.vn')
        d = {}
        d['dictInstrument'] = self.dictInstrument
        d['date'] = date.today()
        f['instrument'] = d
        f.close()
開發者ID:280185386,項目名稱:vnpy,代碼行數:104,代碼來源:demoEngine.py

示例3: __init__

# 需要導入模塊: from eventEngine import EventEngine [as 別名]
# 或者: from eventEngine.EventEngine import stop [as 別名]

#.........這裏部分代碼省略.........
        
    #----------------------------------------------------------------------
    def getAccountPosition(self, event):
        """循環查詢賬戶和持倉"""
        # self.countGet = self.countGet + 1
        #
        # # 每5秒發一次查詢
        # if self.countGet > 5:
        #     self.countGet = 0   # 清空計數
        #
        #     if self.lastGet == 'Account':
        #         self.getPosition()
        #         self.lastGet = 'Position'
        #     else:
        #         self.getAccount()
        #         self.lastGet = 'Account'
    
    #----------------------------------------------------------------------
    def initGet(self, event):
        """在交易服務器登錄成功後,開始初始化查詢"""
        # 打開設定文件setting.vn
        # f = shelve.open('setting.vn')
        #
        # # 嘗試讀取設定字典,若該字典不存在,則發出查詢請求
        # try:
        #     d = f['instrument']
        #
        #     # 如果本地保存的合約數據是今日的,則載入,否則發出查詢請求
        #     today = date.today()
        #     if d['date'] == today:
        #         self.dictInstrument = d['dictInstrument']
        #
        #         # event = Event(type_=EVENT_LOG)
        #         # log = u'合約信息讀取完成'
        #         # event.dict_['log'] = log
        #         # self.ee.put(event)
        #         #
        #         # self.getInvestor()
        #         #
        #         # # 開始循環查詢
        #         # self.ee.register(EVENT_TIMER, self.getAccountPosition)
        #     else:
        #         self.getInstrument()
        # except KeyError:
        #     self.getInstrument()
        #
        # f.close()
 
    #----------------------------------------------------------------------
    def insertInstrument(self, event):
        """插入合約對象"""
        # data = event.dict_['data']
        # last = event.dict_['last']
        #
        # self.dictInstrument[data['InstrumentID']] = data
        #
        # # 合約對象查詢完成後,查詢投資者信息並開始循環查詢
        # if last:
        #     # 將查詢完成的合約信息保存到本地文件,今日登錄可直接使用不再查詢
        #     self.saveInstrument()
            
            # event = Event(type_=EVENT_LOG)
            # log = u'合約信息查詢完成'
            # event.dict_['log'] = log
            # self.ee.put(event)
            #
            # self.getInvestor()
            #
            # # 開始循環查詢
            # self.ee.register(EVENT_TIMER, self.getAccountPosition)
        
    #----------------------------------------------------------------------
    def selectInstrument(self, instrumentid):
        """獲取合約信息對象"""
        # try:
        #     instrument = self.dictInstrument[instrumentid]
        # except KeyError:
        #     instrument = None
        # return instrument
    
    #----------------------------------------------------------------------
    def exit(self):
        """退出"""
        # 銷毀API對象
        # self.td = None
        # self.md = None
        self.dsa = None
        
        # 停止事件驅動引擎
        self.ee.stop()
        
    #----------------------------------------------------------------------
    def saveInstrument(self):
        """保存合約屬性數據"""
        # f = shelve.open('setting.vn')
        # d = {}
        # d['dictInstrument'] = self.dictInstrument
        # d['date'] = date.today()
        # f['instrument'] = d
        # f.close()
開發者ID:zheng-zy,項目名稱:LearnPyqt,代碼行數:104,代碼來源:demoEngine.py


注:本文中的eventEngine.EventEngine.stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。