Api websocket and marketdata websocket


I am creating two websocket connections in different threads. I create a marketdata websocket connecting to

I can subscribe to a particular future and get the market data.

I create another websocket to
The websocket comes up successfully but when I create a sample place order request like this



accountSpec is username returned from authentication
accountId is the integer account id

I get this response
{'s': 200, 'i': 0, 'd': {'failureReason': 'UnknownReason', 'failureText': 'Access is denied'}}

I am not sure why I am getting access denied. I noticed that there are two access tokens when I authenticate. There’s an accessToken and a mdAccessToken.

Why am I getting an access deniedd when trying to send buy/sell orders? I do not get any errors when sending orders to the marketdata websocket.

Also, does the sequence number need to be unique across the entire session or unique for each of the websocket connections?

Solving my own issue based on the response here: Can trade in demo account, having trouble with live account - #10 by Alexander

You need to call the account list endpoint, get the demo account userspec and userid, use that with when routing the orders and everything should work as expected.

1 Like

hi, which attribute from account list endpoint passing to ‘accountSpec’ in placeorder endpoint.

Appreciate your help!

when u get the access token response

accountSpec is name from access token response
accountId is userId from access token response

accountSpec is the name field from the accessTokenRequest (docs) response, correct. But the accountId you need to get from the /account/list operation (docs). Then you can choose one of your accounts. Typical users have a single account but it isn’t unheard of to have multiples. The userId field is used for things like starting a subscription to real-time data for your user.

Thanks for the clarification.

There are the get account list and get user lists will provide more complete information.