Question about market data subscription syntax

Hi everyone – me again. I was able to resolve my websockets connectivity issue yesterday. The issue turned out to indeed be wscat as it worked in the general websockets library. I was able to receive socket authorization.

I have a question regarding the market data subscription syntax → when i send another stream via websockets in order to subscribe to market data, I don’t get any response from the server. just continued heartbeat frames, despite the fact that I have sent the next websocket request via ws.send. Here’s the data I’m sending in a string. If anyone can tell me if I’m interpreting the syntax incorrectly on the API that would be immensely appreciated.

quote_data = {“symbol”:“ESM1”}

ws.send(“md/subscribeQuote\n2\n\n” + json.dumps(quote_data))

thanks

The endpoint for standard real-time websockets is different from the market data endpoint. You need to make sure your websocket is connected to the appropriate url. In market data’s case, 'wss://md.tradovateapi.com/v1/websocket'. Are you connected to the correct websocket address?

1 Like

thanks Alexander – quick question. when market is closed and you submit subscription, does server return any message?

You will get the subscription response (containing the real-time subscription ID) when the market is closed, but no further quote responses.

1 Like

When you are debugging this, open the network tab. Look at the market data socket and ensure that you are sending heartbeat frames every ~2.5 seconds. One thing that happens when you’re receiving market data via real-time subscription is that heartbeat frames may not fire. It looks like the websocket solution you’re using accounts for both pings and pongs, but if you find that you aren’t sending heartbeats back, you’ll have to rig up a mechanism to do so.

1 Like

Thanks Alex – figured it out. the “ws.ping” functionality is only meant to be used server-side. Had to rig up something manually to just use ws.send("") every 2.5 seconds

1 Like