market_maker/ws/ws_thread.py
def connect(self, endpoint="", symbol="XBTN15", shouldAuth=True):
        '''Connect to the websocket and initialize data stores.'''

        logger.debug("Connecting WebSocket.")
        self.symbol = symbol
        self.shouldAuth = shouldAuth

        # We can subscribe right in the connection querystring, so let's build that.
        # Subscribe to all pertinent endpoints
        subscriptions = [sub + ':' + symbol for sub in ["quote", "trade"]]
        subscriptions += ["instrument"]  # We want all of them
        if self.shouldAuth:
            subscriptions += [sub + ':' + symbol for sub in ["order", "execution"]]
            subscriptions += ["margin", "position"]

        # Get WS URL and connect.
        urlParts = list(urlparse(endpoint))
        urlParts[0] = urlParts[0].replace('http', 'ws')
        urlParts[2] = "/realtime?subscribe=" + ",".join(subscriptions)
        wsURL = urlunparse(urlParts)
        logger.info("Connecting to %s" % wsURL)
        self.__connect(wsURL)
        logger.info('Connected to WS. Waiting for data images, this may take a moment...')

        # Connected. Wait for partials
        self.__wait_for_symbol(symbol)
        logger.info("%s received. Waiting for account...", symbol)
        if self.shouldAuth:
            self.__wait_for_account()
        logger.info('Got all market data. Starting.')
Connect to the websocket and initialize data stores.
Connect to the websocket and initialize data stores.
Connect to the websocket and initialize data stores .
def connect(self, endpoint="", symbol="XBTN15", shouldAuth=True):
        logger.debug("Connecting WebSocket.")
        self.symbol = symbol
        self.shouldAuth = shouldAuth
        subscriptions = [sub + ':' + symbol for sub in ["quote", "trade"]]
        subscriptions += ["instrument"]  
        if self.shouldAuth:
            subscriptions += [sub + ':' + symbol for sub in ["order", "execution"]]
            subscriptions += ["margin", "position"]
        urlParts = list(urlparse(endpoint))
        urlParts[0] = urlParts[0].replace('http', 'ws')
        urlParts[2] = "/realtime?subscribe=" + ",".join(subscriptions)
        wsURL = urlunparse(urlParts)
        logger.info("Connecting to %s" % wsURL)
        self.__connect(wsURL)
        logger.info('Connected to WS. Waiting for data images, this may take a moment...')
        self.__wait_for_symbol(symbol)
        logger.info("%s received. Waiting for account...", symbol)
        if self.shouldAuth:
            self.__wait_for_account()
        logger.info('Got all market data. Starting.')
def connect ( self , endpoint = "" , symbol = "XBTN15" , shouldAuth = True ) : logger . debug ( "Connecting WebSocket." ) self . symbol = symbol self . shouldAuth = shouldAuth subscriptions = [ sub + ':' + symbol for sub in [ "quote" , "trade" ] ] subscriptions += [ "instrument" ] if self . shouldAuth : subscriptions += [ sub + ':' + symbol for sub in [ "order" , "execution" ] ] subscriptions += [ "margin" , "position" ] urlParts = list ( urlparse ( endpoint ) ) urlParts [ 0 ] = urlParts [ 0 ] . replace ( 'http' , 'ws' ) urlParts [ 2 ] = "/realtime?subscribe=" + "," . join ( subscriptions ) wsURL = urlunparse ( urlParts ) logger . info ( "Connecting to %s" % wsURL ) self . __connect ( wsURL ) logger . info ( 'Connected to WS. Waiting for data images, this may take a moment...' ) self . __wait_for_symbol ( symbol ) logger . info ( "%s received. Waiting for account..." , symbol ) if self . shouldAuth : self . __wait_for_account ( ) logger . info ( 'Got all market data. Starting.' )
Connect to the websocket and initialize data stores.
Connect to the websocket and initialize data stores .
'''Connect to the websocket and initialize data stores.''' # We can subscribe right in the connection querystring, so let's build that. # Subscribe to all pertinent endpoints # We want all of them # Get WS URL and connect. # Connected. Wait for partials
self
endpoint
symbol
shouldAuth