Hello!
I am currently using the web sockets API in python. To setup, I make a call to the accesstokenrequest
which returns:
{
"accessToken": "<ACCESS_TOKEN>",
"mdAccessToken": "<MD_TOKEN>",
"expirationTime": "2022-05-29T18:26:54.897Z",
"userStatus": "Active",
"userId": <USER#>,
"name": "<ACCOUNT_NAME>",
"hasLive": true,
"outdatedTaC": false,
"hasFunded": true,
"hasMarketData": true,
"outdatedLiquidationPolicy": false
}
I have been able to successfully stream chart data from the market data apis using the <MD_TOKEN>
. What I am now trying to do is set up a web socket connection for the actual user account. I first tried connecting to the account/list
endpoint, to make sure my web socket connection was valid:
2022-05-29:13:31:15,511 INFO [TradovateSocket.py:52] connection established to wss://demo.tradovateapi.com/v1/websocket
------ sending Trade API ------
authorize
1
"<ACCESS_TOKEN>"
------ end send ------
2022-05-29:13:31:15,562 INFO [TradovateSocket.py:70] [{'s': 200, 'i': 1}]
2022-05-29:13:31:15,562 INFO [TradovateSocket.py:75] Trade API Authorization is complete!
------ sending Trade API ------
account/list
2
{}
------ end send ------
2022-05-29:13:31:15,611 INFO [TradovateSocket.py:111] In handle data frame....
2022-05-29:13:31:15,611 INFO [TradovateSocket.py:115] {'s': 200, 'i': 2, 'd': [{'id': 770141, 'name': 'DEMO<USER#>', 'userId': <USER#>, 'accountType': 'Customer', 'active': True, 'clearingHouseId': 2, 'riskCategoryId': 2, 'autoLiqProfileId': 1, 'marginAccountType': 'Speculator', 'legalStatus': 'Individual', 'archived': False, 'timestamp': '2022-03-17T13:58:17Z'}]}
2022-05-29:13:31:18,112 INFO [TradovateSocket.py:167] Found heartbeat frame
Okay, that seems to workout nicely.
I then tried the user/syncrequest
api and get this:
2022-05-29:13:33:19,830 INFO [TradovateSocket.py:52] connection established to wss://demo.tradovateapi.com/v1/websocket
------ sending Trade API ------
authorize
1
"<ACCESS_TOKEN>"
------ end send ------
2022-05-29:13:33:19,882 INFO [TradovateSocket.py:70] [{'s': 200, 'i': 1}]
2022-05-29:13:33:19,882 INFO [TradovateSocket.py:75] Trade API Authorization is complete!
------ sending Trade API ------
user/syncrequest
2
{"users": [<USER#>]}
------ end send ------
2022-05-29:13:33:19,934 INFO [TradovateSocket.py:111] In handle data frame....
2022-05-29:13:33:19,934 INFO [TradovateSocket.py:115] {'s': 401, 'i': 2, 'd': 'Access is denied'}
2022-05-29:13:33:22,434 INFO [TradovateSocket.py:167] Found heartbeat frame
I’m not sure why I’m getting a 401 error?