Esempio n. 1
0
 def runOrderStatistic(self):
     self._logger.info("src.core.router.Router.runOrder")
     try:
         pass
     except (UtilException, EngineException, Exception) as err:
         errStr = "src.core.router.Router.runOrder: %s" % RouterException(
             err)
         raise RouterException(err)
Esempio n. 2
0
 def runBacktest(self):
     self._logger.info("src.core.router.Router.runBacktest")
     try:
         pass
     except (UtilException, EngineException, Exception) as err:
         errStr = "src.core.router.Router.runBacktest: %s" % RouterException(
             err)
         self._logger.critical(errStr)
         raise RouterException(err)
Esempio n. 3
0
 def stop(self):
     self._logger.info("src.core.router.Router.stop")
     try:
         # stop engine
         self._eventEngine.stop()
         # unregister engine
         self._register.unregister()
         # set start param
         self._start = False
     except (UtilException, EngineException, Exception) as err:
         errStr = "src.core.router.Router.stop: %s" % RouterException(err)
         self._logger.critical(errStr)
         raise RouterException(err)
Esempio n. 4
0
 def start(self):
     self._logger.info("src.core.router.Router.start")
     try:
         # register engine
         self._register.register()
         # start engine
         self._eventEngine.start()
         # set start param
         self._start = True
     except (UtilException, EngineException, Exception) as err:
         errStr = "src.core.router.Router.start: %s" % RouterException(err)
         self._logger.critical(errStr)
         raise RouterException(err)
Esempio n. 5
0
 def runMonitor(self):
     self._logger.info("src.core.router.Router.runMonitor")
     try:
         # update market kline after interval
         if time.time(
         ) - self._marketKlineUpdateTime > self._marketKlineInterval:
             self._logger.info(
                 "src.core.router.Router.runMonitor: updateDBMarketKline")
             self._marketKlineUpdateTime = time.time()
             # update db market kline, async must be false
             self._util.updateDBMarketKline(
                 async=self._asyncMarketKline,
                 timeout=self._syncMarketKlineTimeout)
         # update market ticker after interval, update judge after ticker
         if time.time(
         ) - self._marketTickerUpdateTime > self._marketTickerInterval:
             self._logger.info(
                 "src.core.router.Router.runMonitor: updateDBMarketTicker")
             self._marketTickerUpdateTime = time.time()
             # update db market ticker, async must be false
             self._util.updateDBMarketTicker(
                 async=self._asyncMarketTicker,
                 timeout=self._syncMarketTickerTimeout)
             self._logger.info(
                 "src.core.router.Router.runMonitor: updateDBJudgeMarketTicker"
             )
             # update db judge market ticker, async false only on slow pc
             self._util.updateDBJudgeMarketTicker(
                 async=self._asyncJudge, timeout=self._syncJudgeTimeout)
         # update statistic after interval
         if time.time(
         ) - self._statisticJudgeMarketTickerUpdateTime > self._statisticJudgeMarketTickerInterval:
             self._logger.info(
                 "src.core.router.Router.runMonitor: updateDBStatisticJudge"
             )
             self._statisticJudgeMarketTickerUpdateTime = time.time()
             # update db statistic judge, async false only on slow pc
             self._util.updateDBStatisticJudge(
                 async=self._asyncStatistic,
                 timeout=self._syncStatisticTimeout)
     except (UtilException, EngineException, Exception) as err:
         errStr = "src.core.router.Router.runMonitor: %s" % RouterException(
             err)
         raise RouterException(err)
Esempio n. 6
0
 def initAPP(self):
     self._logger.info("src.core.router.Router.initAPP")
     try:
         self._util.initDB()
         self._util.initDBInfo()
         self._util.initServerLimits()
         self._util.updateDBAccountBalance(
             async=self._asyncAccount, timeout=self._syncAccountTimeout)
         # 暂时可不考虑充提币 耗时约 1min
         self._util.updateDBAccountWithdraw(
             async=self._asyncAccount, timeout=self._syncAccountTimeout)
         # 暂时不同步历史交易 耗时约 2min
         # util.updateDBOrderHistorySync(
         #     async=self._asyncAccount, timeout=self._syncAccountTimeout)
     except (UtilException, EngineException, Exception) as err:
         errStr = "src.core.router.Router.initAPP: %s" % RouterException(
             err)
         self._logger.critical(errStr)
         raise RouterException(err)
Esempio n. 7
0
 def updateAPP(self):
     self._logger.info("src.core.router.Router.updateAPP")
     try:
         # make sure engine start
         if not self._start:
             raise Exception(
                 'ENGINE STAUS ERROR, make sure engine is started.')
         # init first
         self._startTime = time.time()
         # run initServerLimits
         self._util.initServerLimits()
         # run monitor
         while time.time(
         ) - self._startTime < self._timeout or self._timeout == 0:
             self.runMonitor()
             self._logger.info(
                 "src.core.router.Router.updateAPP: sleep epoch for %ss" %
                 self._epoch)
             time.sleep(self._epoch)
     except (UtilException, EngineException, Exception) as err:
         errStr = "src.core.router.Router.updateAPP: %s" % RouterException(
             err)
         self._logger.critical(errStr)
         raise RouterException(err)