Hi,
I'm a Python beginner but an Excel Expert.
To cut a long story short i have an excel application which uses REST API but i want to upgrade some of the datafeeds to be websocket.
Python seems to be able to "subscribe" to Websockets but i have no idea how i would get that data streamed over to my User Interface in Excel.
Is this something xlWings can do?
Thanks
import websockets
import asyncio
import json
async def main():
uri = "wss://www.bitmex.com/realtime"
async with websockets.connect(uri) as websocket:
# Send a message to subscribe to XBTUSD updates
msg = {
"op": "subscribe",
"args": ["orderBookL2_25:XBTUSD"]
}
await websocket.send(json.dumps(msg))
# Receive messages in a loop and print them out
while True:
result = await websocket.recv()
data = json.loads(result)
#print(json.dumps(data))
print((data))
if __name__ == "__main__":
# Run the 'main' function in an asyncio event loop
loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever()