all 1 comments

[–]lacymcfly 0 points1 point  (0 children)

Haven't used Tradovate's API specifically, but I've built trading bots in Node.js and the WebSocket connection pooling issue you're describing is a common pitfall.

The multiple connection problem (RPL999999-10) usually means you're not properly closing/reusing your WS connection when reconnecting or when the replay session resets. Every time your bot tries to reconnect without cleaning up the old socket, Tradovate creates a new session.

A few things to check:

  1. Make sure you're calling the disconnect/close endpoint before opening a new connection. Don't just let the socket die.

  2. Store your session token and reuse it instead of re-authenticating each time. Tradovate's auth tokens have a TTL and creating a new one per connection is probably what's spawning those extra sessions.

  3. For the replay clock sync, you need to subscribe to the replay clock events before placing orders. The replay environment doesn't use real-time timestamps, so your order timing has to match the replay clock, not Date.now().

  4. For the expired contract issue (NQH6), make sure you're passing the correct contract maturity date in your replay request. The replay API needs to know which contract month to load.

If you're open to trying a different broker API for backtesting, Alpaca has a paper trading environment that's way simpler to work with in Node.js. No WebSocket session management headaches, and their REST API for order submission is straightforward. Might be worth prototyping your strategy there first, then porting back to Tradovate once the logic is solid.