I am using the Alpca api to create a stock trading algorithm with Python. I can stream quote and minute bar data through the web socket using:
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:
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?
We can connect to multiple websockets in parallel using Python threading module.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.