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


Python eventEngine.EventEngine類代碼示例

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


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

示例1: __init__

 def __init__(self):
     """Constructor
     :type self: object
     """
     self.ee = EventEngine()         # 創建事件驅動引擎
     
     self.md = DemoMdApi(self.ee)    # 創建API接口
     self.td = DemoTdApi(self.ee)
     
     self.ee.start()                 # 啟動事件驅動引擎
     self.havedposi = False
     self.position = {}
     self.todayposition = {}
     
     self.__orders = {}
     self.__retry = 0
     # 循環查詢持倉和賬戶相關
     self.countGet = 0               # 查詢延時計數
     self.lastGet = 'Account'        # 上次查詢的性質
     self.ee.register(EVENT_TDLOGIN, self.initGet)  # 登錄成功後開始初始化查詢
     
     # 合約儲存相關
     self.dictInstrument = {}        # 字典(保存合約查詢數據)
     self.ee.register(EVENT_INSTRUMENT, self.insertInstrument)
     
     self.ee.register(EVENT_TRADE_DATA, self.get_trade)
     self.ee.register(EVENT_ORDER_DATA, self.get_order)
     self.ee.register(EVENT_ERROR, self.get_error)
     self.ee.register(EVENT_MARKETDATA_DATA, self.get_data)
     self.ee.register(EVENT_POSITION_DATA, self.get_position)
開發者ID:lukesummer,項目名稱:ctp,代碼行數:30,代碼來源:demoEngine.py

示例2: __init__

 def __init__(self):
     """Constructor"""
     self.ee = EventEngine()         # 創建事件驅動引擎
     
     self.md = DemoMdApi(self.ee)    # 創建API接口
     self.td = DemoTdApi(self.ee)
     
     self.ee.start()                 # 啟動事件驅動引擎
     
     # 循環查詢持倉和賬戶相關
     self.countGet = 0               # 查詢延時計數
     self.lastGet = 'Account'        # 上次查詢的性質
     self.ee.register(EVENT_TDLOGIN, self.initGet)  # 登錄成功後開始初始化查詢
     
     # 合約儲存相關
     self.dictInstrument = {}        # 字典(保存合約查詢數據)
     self.ee.register(EVENT_INSTRUMENT, self.insertInstrument)
開發者ID:280185386,項目名稱:vnpy,代碼行數:17,代碼來源:demoEngine.py

示例3: __init__

    def __init__(self):
        """Constructor"""
        self.ee = EventEngine()         # 創建事件驅動引擎

        self.dsa = DemoStockApi(('192.168.16.59', 9991), self.ee)    # 現貨報單
        self.dma = DemoMarketApi(('10.10.1.186', 9101), self.ee)    # 現貨報單
        # self.md = DemoL2Api(self.ee)   # 如果使用L2行情就改為這行
        # self.td = DemoTdApi(self.ee)

        self.ee.start()                 # 啟動事件驅動引擎

        # 循環查詢持倉和賬戶相關
        self.countGet = 0               # 查詢延時計數
        self.lastGet = 'Account'        # 上次查詢的性質
        # self.ee.register(EVENT_TDLOGIN, self.initGet)  # 登錄成功後開始初始化查詢
        
        # 合約儲存相關
        self.dictInstrument = {}        # 字典(保存合約查詢數據)
開發者ID:zheng-zy,項目名稱:LearnPyqt,代碼行數:18,代碼來源:demoEngine.py

示例4: __init__

    def __init__(self, ws, account, justCopySignal=False):
        """Constructor
        :type self: object
        """
        self.ee = EventEngine(account,ws)         # 創建事件驅動引擎
        self.justCopySignal = justCopySignal

        self.userid = account['userid']
        self.password = account['password']
        self.brokerid = account['brokerid']
        self.mdaddress = account['mdAddress']
        self.tdaddress = account['tdAddress']

        self.md = DemoMdApi(self.ee, self.mdaddress, self.userid, self.password, self.brokerid)    # 創建API接口
        self.td = DemoTdApi(self.ee, self.tdaddress, self.userid, self.password, self.brokerid)

        self.ee.start()                 # 啟動事件驅動引擎
        self.havedposi = False
        self.position = {}
        self.todayposition = {}
        
        self.__orders = {}
        self.__retry = 0
        # 循環查詢持倉和賬戶相關
        self.countGet = 0               # 查詢延時計數
        self.lastGet = 'Account'        # 上次查詢的性質
        self.ee.register(EVENT_TDLOGIN, self.initGet)  # 登錄成功後開始初始化查詢
        
        # 合約儲存相關
        self.dictInstrument = {}        # 字典(保存合約查詢數據)
        self.ee.register(EVENT_INSTRUMENT, self.insertInstrument)
        
        self.ee.register(EVENT_TRADE_DATA, self.get_trade)
        self.ee.register(EVENT_ORDER_DATA, self.get_order)
        self.ee.register(EVENT_ERROR, self.get_error)
        self.ee.register(EVENT_MARKETDATA_DATA, self.get_data)
        self.ee.register(EVENT_POSITION_DATA, self.get_position)
開發者ID:wangdkchina,項目名稱:web_ctp,代碼行數:37,代碼來源:demoEngine.py

示例5: __init__

    def __init__(self, account, _plus_path, bg):

        self.ee = EventEngine(account)         # 創建事件驅動引擎
        self.bridge = bg
        self.__lock = Lock()
        self.userid = str(account['userid'])
        self.password = str(account['password'])
        self.brokerid = str(account['brokerid'])
        self.mdaddress = str(account['mdfront'])
        self.tdaddress = str(account['tdfront'])
        self.instrument = account['instrument'] #   sub list str
        self.pluspath = _plus_path

        self.dictInstrument = {}        # 字典(保存合約查詢數據)
        self.dictProduct = {}        # 字典(保存合約查詢數據)
        self.dictExchange= {}
        self.tmpInstrument = {}        # 字典(保存合約查詢數據)
        self.tmpProduct = {}        # 字典(保存合約查詢數據)
        self.tmpExchange= {}
        self.dictUpdate = None
        self.subInstrument = set()
        self.subedInstrument = set()
        self.master = {}    #   記錄主力合約對應關係
        self.masterSubed = False
        self.subedMaster = {}
        self.tickpass = set()
        self.now = datetime.now()
        self.socket = None
        self.coreServer = str(account['zmqserver'])
        self.corefunc = passit
        if int(account['usezmq'])>0:
            if self.coreServer[:4] == 'tcp:':
                context = zmq.Context()
                socket = context.socket(zmq.REQ)
                socket.connect(self.coreServer)
                self.socket = socket
                self.corefunc = tcpfunc
            elif self.coreServer[:5] == 'http:':
                self.socket = True
                self.corefunc = httpfunc
        self.ee.start()                 # 啟動事件驅動引擎
        self.som = {}

        self.lastError = 0
        self.lastTodo = 0

        self.eq = 0

        # 循環查詢持倉和賬戶相關
        self.countGet = 0               # 查詢延時計數
        self.lastGet = 'Account'        # 上次查詢的性質
        self.ee.register(EVENT_TDLOGIN, self.initGet,True)  # 登錄成功後開始初始化查詢

        self.__timer = time()+3
        self.__readySubscribe = {}
        
        # 合約儲存相關

        self.get_instrument()
        self.get_subscribe(self.instrument)
        self.ee.register(EVENT_MDLOGIN,     self.ready_subscribe,True)
        self.ee.register(EVENT_TDLOGIN,     self.ready_subscribe,True)
        self.ee.register(EVENT_ERROR,       self.get_error,False)
        self.ee.register(EVENT_INSTRUMENT,  self.insertInstrument,True)
        self.ee.register(EVENT_TIMER,       self.getAccountPosition,False)
        self.ee.register(EVENT_TRADE,       self.get_trade,False)
        self.ee.register(EVENT_ORDER,       self.get_order,False)
        self.ee.register(EVENT_TICK,        self.get_tick,True)
        self.ee.register(EVENT_POSITION,    self.get_position,False)
        self.ee.register(EVENT_ACCOUNT,     self.get_account,False)

        self.ee.register(EVENT_TICK,        self.check_timer,False)
        self.ee.register(EVENT_ORDER,       self.check_timer,False)

        import eventType
        for k,v in eventType.__dict__.items():
            if 'EVENT_' in k and v[0]!='_':
                self.ee.register(v,self.websocket_send,False)

        self.md = ctpMdApi(self, self.mdaddress, self.userid, self.password, self.brokerid, plus_path=_plus_path)    # 創建API接口
        self.td = ctpTdApi(self, self.tdaddress, self.userid, self.password, self.brokerid, plus_path=_plus_path)
開發者ID:yooohooog,項目名稱:web_ctp,代碼行數:81,代碼來源:ctpEngine.py

示例6: __init__

    def __init__(self, ws, account, _plus_path, justCopySignal=False, useZmq = False, zmqServer = "tcp://localhost:9999"):
        """Constructor
        :type self: object
        """
        self.ee = EventEngine(account)         # 創建事件驅動引擎
        self.justCopySignal = justCopySignal

        self.userid = str(account['userid'])
        self.password = str(account['password'])
        self.brokerid = str(account['brokerid'])
        self.mdaddress = str(account['mdfront'])
        self.tdaddress = str(account['tdfront'])

        self.pluspath = _plus_path
        self.symbol = None
        self.socket = None
        self.websocket = ws             # websocket list to send msg

        if useZmq:
            context = zmq.Context()
            socket = context.socket(zmq.REQ)
            socket.connect(zmqServer)
            self.socket = socket

        self.ee.start()                 # 啟動事件驅動引擎
        self.havedposi = False
        self.position = {}
        self.todayposition = {}
        self.lastError = 0
        self.lastTodo = 0

        self.__timer = time()+60
        self.__orders = {}
        self.__retry = 0
        self.__maxRetry = 5
        # 循環查詢持倉和賬戶相關
        self.countGet = 0               # 查詢延時計數
        self.lastGet = 'Account'        # 上次查詢的性質
        self.ee.register(EVENT_TDLOGIN, self.initGet)  # 登錄成功後開始初始化查詢
        
        # 合約儲存相關
        self.dictInstrument = {}        # 字典(保存合約查詢數據)
        self.dictProduct = {}        # 字典(保存合約查詢數據)
        self.dictExchange= {}
        self.volInstrument = {}
        self.subInstrument = set()
        self.subedInst = set()
        
        self.price = {} #   存儲報價,分品種

        self.todo = 0

        self.ee.register(EVENT_ERROR,       self.get_error)
        self.ee.register(EVENT_INSTRUMENT,  self.insertInstrument)
        self.ee.register(EVENT_TIMER,       self.getAccountPosition)
        self.ee.register(EVENT_TRADE,       self.get_trade)
        self.ee.register(EVENT_ORDER,       self.get_order)
        self.ee.register(EVENT_TICK,        self.get_tick)
        self.ee.register(EVENT_POSITION,    self.get_position)

        import eventType
        for k,v in eventType.__dict__.items():
            if 'EVENT_' in k and v[0]!='_':
                self.ee.register(v,self.websocket_send)

        self.md = DemoMdApi(self.ee, self.mdaddress, self.userid, self.password, self.brokerid,plus_path=_plus_path)    # 創建API接口
        self.td = DemoTdApi(self.ee, self.tdaddress, self.userid, self.password, self.brokerid,plus_path=_plus_path)
開發者ID:yieio,項目名稱:web_ctp,代碼行數:67,代碼來源:demoEngine.py


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