[英]How do I stream data from two different web sockets at the same time using the websocket.WebsocketApp in python?
I am using the Alpca api to create a stock trading algorithm with Python.我正在使用 Alpca api 使用 Python 创建股票交易算法。 I can stream quote and minute bar data through the web socket using:我可以通过 web 套接字使用 stream 报价和分钟柱数据:
socket = "wss://data.alpaca.markets/stream"
ws = websocket.WebSocketApp(socket, on_open=on_open, on_message=on_message,
on_close=on_close)
ws.run_forever()
However, I need to stream trade_update data at the same time from a different socket:但是,我需要同时从不同的套接字 stream trade_update 数据:
socket = "wss://paper-api.alpaca.markets/stream "
How do I stream data from two different web sockets at the same time using the format above in python?如何使用 Z23EEEB4347BDD26B5FC6B777 中的上述格式同时使用来自两个不同 web sockets 的 stream 数据?
We can connect to multiple websockets in parallel using Python threading module.我们可以使用 Python 线程模块并行连接到多个 websocket。
Reference: https://steemit.com/utopian-io/@steempytutorials/part-3-connecting-and-managing-multiple-websocket-streams-in-parallel参考: https://steemit.com/utopian-io/@steempytutorials/part-3-connecting-and-managing-multiple-websocket-streams-in-parallel
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.