# Problems while implementing trade updates streaming

**URL:** <https://forum.alpaca.markets/t/problems-while-implementing-trade-updates-streaming/2742>\
**Category:** Alpaca Market Data\
**Created:** [September 22, 2020, 5:15pm UTC](https://forum.alpaca.markets/t/problems-while-implementing-trade-updates-streaming/2742 "2020-09-22T17:15:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alinvest](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@Alinvest](https://forum.alpaca.markets/u/Alinvest)\
**Post date:** [September 22, 2020, 5:15pm UTC](https://forum.alpaca.markets/t/problems-while-implementing-trade-updates-streaming/2742/1 "2020-09-22T17:15:45Z")

</div>

Hi everyone!  
We are trying to recive our account’s trade updates along with the stream of the quotes. However, we don’t understand how to implement the trade updates. This is the code we are developing (it doesn’t work):

> query\_list = [‘Q.’+q for q in stockUniverse] + [‘trade\_updates’]

> #stockUniverse is a list of stocks

> def on\_open(ws):  
> print(“opened”)  
> auth\_data = {“action”: “authenticate”, “data”: {“key\_id”: api\_key, “secret\_key”: api\_secret}}  
> ws.send(json.dumps(auth\_data))  
> query = {“action”: “listen”, “data”: {“streams”: query\_list}}  
> ws.send(json.dumps(query))

> def on\_message(ws, message):  
> print(message)

> ws=websocket.WebSocketApp(streamURL, on\_open = on\_open, on\_message = on\_message)  
> ws.run\_forever()

Could you help us?  
Thanks!

---

<div class="post-metadata">

**Author:** ![Shlomik](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/shlomik/32/793_2.png) [@Shlomik](https://forum.alpaca.markets/u/Shlomik)\
**Post date:** [September 23, 2020, 3:45pm UTC](https://forum.alpaca.markets/t/problems-while-implementing-trade-updates-streaming/2742/2 "2020-09-23T15:45:36Z")

</div>

Hi, here’s an example algorithm to receive websocket stream (updates, quotes, trades, …)  
okay with it to learn what you are looking for.

> <https://github.com/alpacahq/alpaca-trade-api-python/blob/extend_websocket_example/examples/websocket_example.py>

---

<div class="post-metadata">

**Author:** ![rossjeremyd](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@rossjeremyd](https://forum.alpaca.markets/u/rossjeremyd)\
**Post date:** [March 2, 2023, 1:33am UTC](https://forum.alpaca.markets/t/problems-while-implementing-trade-updates-streaming/2742/4 "2023-03-02T01:33:21Z")

</div>

can you reshare this? The link to full code doesn’t work
