Beispiel #1
0
    def handleResponse(self, msg):
        ret = msg.get("event") == "pusher:pong"

        if ret:
            logger.debug("Received pusher:pong.")

        return ret
Beispiel #2
0
 def run(self):
     logger.debug("Thread started.")
     while not self.__stopped:
         self.__wait()
         if not self.__stopped:
             try:
                 self.doCall()
             except Exception as e:
                 logger.critical("Unhandled exception", exc_info=e)
     logger.debug("Thread finished.")
Beispiel #3
0
    def doCall(self):
        endDateTime = self.__nextBarClose
        barDict = {}

        self.__updateNextBarClose()

        for indentifier in self.__identifiers:
            try:
                logger.debug(
                    "Requesting bars with precision {} and period {} for {}".
                    format(self.__precision, self.__period, indentifier))
                response = api.XigniteGlobalRealTime_GetBar(
                    self.__apiToken, indentifier, "Symbol", endDateTime,
                    self.__precision, self.__period)
                # logger.debug(response)
                barDict[indentifier] = build_bar(response["Bar"], indentifier,
                                                 self.__frequency)
            except api.XigniteError as e:
                logger.error(e)

        if len(barDict):
            bars = bar.Bars(barDict)
            self.__queue.put((GetBarThread.ON_BARS, bars))
Beispiel #4
0
 def sendKeepAlive(self):
     logger.debug("Sending pusher:ping.")
     self.getWSClient().sendPing()