I’m able to log into my paper trading account and authorize my account with the code below, and it appears that I successfully subscribe to my account stream according to the messages I get from the websocket, but then I don’t receive any account updates after I manually enter trades into my paper account to test this.
Can somebody tell me if I’m doing something wrong here, or if paper accounts don’t have the functionality to send account updates via websocket?
def on_open(ws):
auth_data = {
“action”: “authenticate”,
“data”: {
“key_id”: alpaca_api_key,
“secret_key”: alpaca_secret_key
}
}
ws.send(json.dumps(auth_data))
print(‘open’)
listen_message = {
"action": "listen",
"data": {
"streams": ["trade_updates"]
}
}
ws.send(json.dumps(listen_message))
print("listening...")
def on_message(ws, message):
json_message = json.loads(message)
print(json_message)
ws = websocket.WebSocketApp(base_url, on_open=on_open, on_message=on_message)
ws.run_forever()
this code outputs:
open
listening…
{‘stream’: ‘authorization’, ‘data’: {‘action’: ‘authenticate’, ‘status’: ‘authorized’}}
{‘stream’: ‘listening’, ‘data’: {‘streams’: [‘trade_updates’]}}