Replay Sessions Q&A

I had a conversation with @Rob_Hoskins about replay sessions that deserves a topic. Rob had asked me about a bug he had found, but the more important part of the conversation followed:

Q:

A: Yes it’s completely possible, check out this section of the API docs:
https://api.tradovate.com/#section/Request-Examples/Market-Replay
You’ll want to use it with a websocket, so use the wss://replay.tradovateapi.com/v1/websocket address.

Q:

A: That’s correct, the API is split into domains based on the function you’re looking to utilize. You would gain access using the typical https://demo... or https://live... URLs and use the wss://replay... URL with a websocket for replay related calls. As for market data, that’s a lot of what replay is all about. Using a websocket that has been configured for a replay session (by using the replay wss URL and initializing the clock using the replay/initializeClock endpoint), you send a market data request just like you would with a websocket looking at the md endpoint md/subscribeQuote or md/subscribeDOM etc.

Q:

A: In order to use the pre-made socket classes I built you’ll need to do some re-configuring. The gist is that you’ll use the replay URL in a websocket to make an md/subscribeQuote call.

It may work if you just change the MarketDataSocket’s URL to the replay URL instead of the market data URL, given that you’re not already using that implementation. If you are actively using the md socket for something else then you could always just extend the TradovateSocket again. Basically you’d copy paste all the market data socket’s implementation and change the base URL to the replay URL.

Q:

A: Yes, technically each time you call initializeClock you set a new session for your user. That session is unique to your user, so its the same session when you see it from the UI and the API. Until you call initializeClock again, you’ll have the same session on both UI and API.

Q:

A: The replay session is reset every time you call initializeClock, so you can’t save old sessions, but you could keep track of the parameters you used and re-run them. And the time-horizon entitlements come into play - you need to purchase more history if you want to go way back in time, or replay a large amount of time.

Please feel free to add any other Replay related questions to this thread!