コード例 #1
0
ファイル: base_engine.py プロジェクト: qsq-dm/easyquant
 def push_quotation(self):
     while self.is_active:
         try:
             response_data = self.fetch_quotation()
         except aiohttp.errors.ServerDisconnectedError:
             time.sleep(self.PushInterval)
             continue
         event = Event(event_type=self.EventType, data=response_data)
         self.event_engine.put(event)
         time.sleep(self.PushInterval)
コード例 #2
0
ファイル: base_engine.py プロジェクト: yushb0602/trader
 def push_quotation(self):
     while self.is_active:
         try:
             response_data = self.fetch_quotation()
         except:
             self.wait()
             continue
         event = Event(event_type=self.EventType, data=response_data)
         self.event_engine.put(event)
         self.wait()
コード例 #3
0
 def push_quotation(self):
     while self.is_active:
         try:
             self.stocks = self.feedback_queue.get(block=True, timeout=1)
             response = self.fetch_quotation()
         except Empty:
             continue
         event = Event(event_type=self.EventType, data=response)
         self.event_engine.put(event)
         time.sleep(self.pause)
コード例 #4
0
 def push_quotation(self):
     while self.is_active:
         try:
             response_lists = self.fetch_quotation()
         except:
             self.wait()
             continue
         for response in response_lists:
             event = Event(event_type=self.EventType, data=response)
             self.event_engine.put(event)
             time.sleep(self.pause)
         self.wait()
コード例 #5
0
ファイル: quotation_engine.py プロジェクト: winglq/easyquant
    def push_quotation(self):
        while self.is_active:

            if not etime.is_tradetime(datetime.now()):
                self.wait()
                continue

            try:
                response_data = self.fetch_quotation()
            except:
                self.wait()
                continue
            event = Event(event_type=self.EventType, data=response_data)
            self.event_engine.put(event)
            self.wait()
コード例 #6
0
 def push_quotation(self):
     try:
         while self.is_active:
             events = self.epoll.poll(self.timeout)
             if not events:
                 continue
             for fd, event in events:
                 socket = self.fd_to_socket[fd]
                 if socket == self.serversocket:
                     connection, address = self.serversocket.accept()
                     connection.setblocking(False)
                     self.epoll.register(connection.fileno(),
                                         select.EPOLLIN)
                     self.fd_to_socket[connection.fileno()] = connection
                     self.message_queues[connection] = queue.Queue()
                 elif event & select.EPOLLHUP:
                     self.epoll.unregister(fd)
                     self.fd_to_socket[fd].close()
                     del self.fd_to_socket[fd]
                 elif event & select.EPOLLIN:
                     tmpbuf = socket.recv(10240)
                     if not len(tmpbuf):
                         self.epoll.modify(fd, select.EPOLLHUP)
                     if tmpbuf.endswith(b'EOF'):
                         self.buf += tmpbuf
                         self.message_queues[socket].put(
                             self.buf.decode('utf-8')[:-3])
                         self.buf = b''
                         tmpbuf = b''
                         self.epoll.modify(fd, select.EPOLLOUT)
                     else:
                         self.buf += tmpbuf
                 elif event & select.EPOLLOUT:
                     try:
                         response_str = self.message_queues[
                             socket].get_nowait()
                     except queue.Empty:
                         self.epoll.modify(fd, select.EPOLLIN)
                     else:
                         response_dict = json.loads(response_str)
                         event_req = Event(event_type=self.EventType,
                                           data=response_dict)
                         self.event_engine.put(event_req)
     finally:
         self.epoll.unregister(self.serversocket.fileno())
         self.epoll.close()
         self.serversocket.close()
コード例 #7
0
ファイル: base_engine.py プロジェクト: StevenLOL/easyquant
 def push_quotation(self):
     while self.is_active:
         response_data = self.fetch_quotation()
         event = Event(event_type=self.EventType, data=response_data)
         self.event_engine.put(event)
         time.sleep(self.PushInterval)