(self,zmq_context,trade_pub_connection_string,trade_client)
return trade_client.sendJSON(md_subscription_msg)
subscribe.
subscribe.
subscribe .
def subscribe(self,zmq_context,trade_pub_connection_string,trade_client):

        """" subscribe. """
        self.md_pub_socket = zmq_context.socket(zmq.SUB)
        self.md_pub_socket.connect(trade_pub_connection_string)
        self.md_pub_socket.setsockopt(zmq.SUBSCRIBE,"^MD_FULL_REFRESH_" +self.symbol + '$')
        self.md_pub_socket.setsockopt(zmq.SUBSCRIBE,"^MD_TRADE_" + self.symbol + '$')
        self.md_pub_socket.setsockopt(zmq.SUBSCRIBE,"^MD_INCREMENTAL_" +self.symbol +".0$")
        self.md_pub_socket.setsockopt(zmq.SUBSCRIBE,"^MD_INCREMENTAL_" +self.symbol +".1$")

        self.md_pub_socket_stream = ZMQStream(self.md_pub_socket)
        self.md_pub_socket_stream.on_recv(self.on_md_publish)

        md_subscription_msg = {
            'MsgType': 'V',
            'MDReqID': '0',  # not important.
            'SubscriptionRequestType': '0',
            'MarketDepth': 0,
            'TradeDate': time.strftime("%Y%m%d", time.localtime()),
            'MDUpdateType': '0',
            'MDEntryTypes': ['0', '1', '2'],
            'Instruments': [self.symbol]
        }

        self.application.log('DEBUG', 'MARKET_DATA_SUBSCRIBER', 'SUBSCRIBE' )

        return trade_client.sendJSON(md_subscription_msg)
def subscribe ( self , zmq_context , trade_pub_connection_string , trade_client ) : self . md_pub_socket = zmq_context . socket ( zmq . SUB ) self . md_pub_socket . connect ( trade_pub_connection_string ) self . md_pub_socket . setsockopt ( zmq . SUBSCRIBE , "^MD_FULL_REFRESH_" + self . symbol + '$' ) self . md_pub_socket . setsockopt ( zmq . SUBSCRIBE , "^MD_TRADE_" + self . symbol + '$' ) self . md_pub_socket . setsockopt ( zmq . SUBSCRIBE , "^MD_INCREMENTAL_" + self . symbol + ".0$" ) self . md_pub_socket . setsockopt ( zmq . SUBSCRIBE , "^MD_INCREMENTAL_" + self . symbol + ".1$" ) self . md_pub_socket_stream = ZMQStream ( self . md_pub_socket ) self . md_pub_socket_stream . on_recv ( self . on_md_publish ) md_subscription_msg = { 'MsgType' : 'V' , 'MDReqID' : '0' , # not important. 'SubscriptionRequestType' : '0' , 'MarketDepth' : 0 , 'TradeDate' : time . strftime ( "%Y%m%d" , time . localtime ( ) ) , 'MDUpdateType' : '0' , 'MDEntryTypes' : [ '0' , '1' , '2' ] , 'Instruments' : [ self . symbol ] } self . application . log ( 'DEBUG' , 'MARKET_DATA_SUBSCRIBER' , 'SUBSCRIBE' ) return trade_client . sendJSON ( md_subscription_msg )