コード例 #1
0
 def sendOrderHistorySyncEvent(self, exchange, fSymbol, tSymbol, limit,
                               ratio):
     try:
         # 构造事件对象
         TEMP_EVENT = json.loads(
             ORDER_HISTORY_SYNC_EVENT.substitute(
                 id=self._engine.getEventID(),
                 timeStamp=utcnow_timestamp(),
                 exchange=exchange,
                 fSymbol=fSymbol,
                 tSymbol=tSymbol,
                 limit=limit,
                 ratio=ratio))
         event = Event(TEMP_EVENT)
         self._logger.debug(
             "src.core.engine.sender.Sender.sendOrderHistorySyncEvent: " +
             json.dumps(TEMP_EVENT))
         # 发送事件
         self._engine.sendEvent(event)
         # 返回参数
         return event.id
     except Exception as err:
         errStr = "src.core.engine.sender.Sender.sendOrderHistorySyncEvent: %s" % EngineException(
             err)
         raise EngineException(errStr)
コード例 #2
0
 def sendListenMarketKlineEvent(self, exchange, fSymbol, tSymbol, interval,
                                start, end):
     try:
         # 构造事件对象
         TEMP_EVENT = json.loads(
             LISTEN_MARKET_KLINE_EVENT.substitute(
                 id=self._engine.getEventID(),
                 timeStamp=utcnow_timestamp(),
                 exchange=exchange,
                 fSymbol=fSymbol,
                 tSymbol=tSymbol,
                 interval=interval,
                 start=start,
                 end=end))
         event = Event(TEMP_EVENT)
         self._logger.debug(
             "src.core.engine.sender.Sender.sendListenMarketKlineEvent: " +
             json.dumps(TEMP_EVENT))
         # 发送事件
         self._engine.sendEvent(event)
         # 返回参数
         return event.id
     except Exception as err:
         errStr = "src.core.engine.sender.Sender.sendListenMarketKlineEvent: %s" % EngineException(
             err)
         raise EngineException(errStr)
コード例 #3
0
 def sendJudgeMarketKlineEvent(self, args):
     try:
         # 构造事件对象
         TEMP_EVENT = json.loads(
             JUDGE_MARKET_KLINE_EVENT.substitute(
                 id=self._engine.getEventID(),
                 timeStamp=utcnow_timestamp(),
                 args=""))
         event = Event(TEMP_EVENT)
         self._logger.debug(
             "src.core.engine.sender.Sender.sendJudgeMarketKlineEvent: " +
             json.dumps(TEMP_EVENT))
         # 发送事件
         pass
     except Exception as err:
         errStr = "src.core.engine.sender.Sender.sendJudgeMarketKlineEvent: %s" % EngineException(
             err)
         raise EngineException(errStr)
コード例 #4
0
 def sendStatiscJudgeEvent(self, exchange, types):
     try:
         # 构造事件对象
         TEMP_EVENT = json.loads(
             STATISTIC_JUDGE_EVENT.substitute(id=self._engine.getEventID(),
                                              timeStamp=utcnow_timestamp(),
                                              exchange=exchange,
                                              types=types))
         event = Event(TEMP_EVENT)
         self._logger.debug(
             "src.core.engine.sender.Sender.sendStatiscJudgeEvent: " +
             json.dumps(TEMP_EVENT))
         # 发送事件
         self._engine.sendEvent(event)
         # 返回参数
         return event.id
     except Exception as err:
         errStr = "src.core.engine.sender.Sender.sendStatiscJudgeEvent: %s" % EngineException(
             err)
         raise EngineException(errStr)
コード例 #5
0
 def sendListenAccountBalanceEvent(self, exchange):
     try:
         # 构造事件对象
         TEMP_EVENT = json.loads(
             LISTEN_ACCOUNT_BALANCE_EVENT.substitute(
                 id=self._engine.getEventID(),
                 timeStamp=utcnow_timestamp(),
                 exchange=exchange))
         event = Event(TEMP_EVENT)
         self._logger.debug(
             "src.core.engine.sender.Sender.sendListenAccountBalanceEvent: "
             + json.dumps(TEMP_EVENT))
         # 发送事件
         self._engine.sendEvent(event)
         # 返回参数
         return event.id
     except Exception as err:
         errStr = "src.core.engine.sender.Sender.sendListenAccountBalanceEvent: %s" % EngineException(
             err)
         raise EngineException(errStr)
コード例 #6
0
 def sendStatiscOrderEvent(self, signals):
     try:
         for signal in signals:
             signal['status_assets'] = json_escape(signal['status_assets'])
         # 构造事件对象
         TEMP_EVENT = json.loads(
             STATISTIC_ORDER_EVENT.substitute(id=self._engine.getEventID(),
                                              timeStamp=utcnow_timestamp(),
                                              signals=signals))
         event = Event(TEMP_EVENT)
         self._logger.debug(
             "src.core.engine.sender.Sender.sendStatiscOrderEvent: " +
             json.dumps(TEMP_EVENT))
         # 发送事件
         self._engine.sendEvent(event)
         # 返回参数
         return event.id
     except Exception as err:
         errStr = "src.core.engine.sender.Sender.sendStatiscOrderEvent: %s" % EngineException(
             err)
         raise EngineException(errStr)
コード例 #7
0
 def sendOrderHistoryCreatEvent(self, exchange, signals, timeout):
     try:
         # 构造事件对象
         TEMP_EVENT = json.loads(
             BACKTEST_HISTORY_CREAT_EVENT.substitute(
                 id=self._engine.getEventID(),
                 timeStamp=utcnow_timestamp(),
                 exchange=exchange,
                 signals=signals,
                 timeout=timeout))
         event = Event(TEMP_EVENT)
         self._logger.debug(
             "src.core.engine.sender.Sender.sendOrderHistoryCreatEvent: " +
             json.dumps(TEMP_EVENT))
         # 发送事件
         self._engine.sendEvent(event)
         # 返回参数
         return event.id
     except Exception as err:
         errStr = "src.core.engine.sender.Sender.sendOrderHistoryCreatEvent: %s" % EngineException(
             err)
         raise EngineException(errStr)