Exemplo n.º 1
0
 def on_tick(self, tick):
     """tick process function"""
     # print(tick)
     # print(self.app.recorder.get_all_positions())
     p = dumps(tick)
     print(p)
     print(loads(p))
Exemplo n.º 2
0
 def on_init(self, init):
     if init:
         self.isok = True
     orders = self.center.orders
     trades = self.recorder.get_all_trades()
     data = {"data": self.center.orders, "trade": trades}
     print("===> ")
     from ctpbee import dumps
     strr = dumps(data)
     with open("data.json", "w") as f:
         f.write(strr)
Exemplo n.º 3
0
 def on_tick(self, tick):
     """ 处理tick推送 """
     if not auth_time(tick.datetime.time()):
         """ 过滤非交易时间的tick """
         return
     try:
         x = dumps(tick)  #
         print(tick.symbol)
         self.pub.pub(x, routing_key=tick.symbol)
     except Exception as e:
         print(e)
Exemplo n.º 4
0
    def on_tick(self, tick):
        """ 处理tick推送 """
        if not auth_time(tick.datetime.time()):
            """ 过滤非交易时间的tick """
            return

        # if tick.symbol == "rb2010":
        #     self.info(
        #         f"买一: {tick.bid_price_1}, 买一量: {tick.bid_volume_1}, 卖一: {tick.ask_price_1}, 卖一量: {tick.ask_volume_1}")
        try:
            setattr(tick, "preSettlementPrice", tick.pre_settlement_price)
            x = dumps(tick)  #
            self.pub.pub(x, routing_key=tick.symbol)

        except Exception as e:
            print(e)
Exemplo n.º 5
0
 def on_tick(self, tick: TickData) -> None:
     p = dumps(tick)
     fancy = EVENT_TICK + "--" + p + "--" + self.key
     p = bytes(fancy, encoding="utf-8") + AUTH_KEY
     self.client.send(p)