Can you place an API trade against replay?

Quick question, is there a rest endpoint for replay? eg. to place orders

I have successfully gotten an access token and placed an order against Demo and Live however I cannot receive an access token from the following replayUrl.

https://demo.tradovateapi.com/v1
https://live.tradovateapi.com/v1
https://replay.tradovateapi.com/v1

Hello @wogann,

You need to use a WebSocket to start a replay session. For more info on using WebSockets to run Replay sessions, check out this section of the docs.

Yes I meant to place a trade against replay? Can I send a socket client request like this in order to place an order?

WebSocket.Send(“order/placeorder\n50\n\n{“AccountSpec”: “RPLxxxxxx-x”,“AccountId”: “”,“ClOrdId”: “”,“Action”: “Buy”,“Symbol”: “MNQZ1”,“OrderQty”: 1,“OrderType”: “Market”,“Price”: “”,“StopPrice”: “”,“MaxShow”: “”,“PegDifference”: “”,“TimeInForce”: “Day”,“ExpireTime”: “”,“Text”: “Sample”,“ActivationTime”: “”,“IsAutomated”: “True”}”);

That’s pretty much exactly how you’d do it.

The Market Replay socket is unique in the sense that it occupies the same functional domains as both the real time socket (wss://live.tradovateapi.com/v1/websocket) and the market data socket (wss://md.tradovateapi.com/v1/websocket). So whether you want market data or to make a trade against replay, you’ll use the same Market Replay socket’s send method.

Hi @Alexander I’m finally circling back on this one. I have not had success so far. I am not sure if I am missing a required field or I am targeting the right replay session since the -x on the end is variable each replay session.

When sending a change to the replay speed it is working and I see the change happen in the UI, so I know I have an active websocket connection to replay and am able to push a correctly formatted message. I believe my issue with /placeorder is the json itself. No issues with the following.

replay/changespeed
49

{ "speed":100}

This however is not working

order/placeorder
5

{"accountSpec": "DEMO123456","accountId": "RPL123456-62","action": "Buy","symbol":"NQU2","orderQty": 1,"orderType": "Market","isAutomated": true }

or

order/placeorder
5

{"AccountSpec": "RPL123456-62","AccountId": "","ClOrdId": "","Action": "Buy","Symbol": "NQU2","OrderQty": 1,"OrderType": "Market","Price": "","StopPrice": "","MaxShow": "","PegDifference": "","TimeInForce": "Day","ExpireTime": "","Text": "Sample","ActivationTime": ""}

or

order/placeorder
5

{"AccountSpec": "DEMO123456","AccountId": "","ClOrdId": "","Action": "Buy","Symbol": "NQU2","OrderQty": 1,"OrderType": "Market","Price": "","StopPrice": "","MaxShow": "","PegDifference": "","TimeInForce": "Day","ExpireTime": "","Text": "Sample","ActivationTime": ""}

I feel like I’m close on this but no luck so far, could you please advise?

Update: I found the response error. I definitely need help with the correct json to send in here.
image

Next update: The first issue here is the AccountSpec is your username, and AccountId is the AccountId without DEMO or RPL prefixed to the integer. Maybe the doc can be more clear here?

order/placeorder
5

{"accountSpec": "userId","accountId": 123456,"action": "Buy","symbol":"NQU2","orderQty": 1,"orderType": "Market","isAutomated": true }

I am now stuck on a ‘Access is denied’, however I have confirmed the token has the maximum permissions possible and full access to the orders endpoint…Will continue.

Were you ever able to figure this out? I’m having the same issue. I believe it’s because the accountId is incorrect. How do we get the accountId for a replay session?

The way I get it for a normal session is the API’s /account/list endpoint, but using that for a replay session just returns my DEMO account ID.

Your accountId is wrong… it should be a number.

as soon as you do an initClock, it will create a brand new account.

userSync events will tell what that account number is at that time when it is created