Read time data stream not working in Jupyter Notebook

Hi I was just trying out the real time quote data function, and it doesn’t seem to run in Jupyter Notebook (VSCode), but seems to run fine as a .py file in PyCharm.

from alpaca.data.live import CryptoDataStream
from config import *

wss_client = CryptoDataStream(API_KEY, SECRET_KEY)

async def quote_data_handler(data):
print(data)

wss_client.subscribe_quotes(quote_data_handler, “BTC/USD”)

wss_client.run()

This returns the error “RuntimeError : asyncio.run() cannot be called from a running event loop”. Does anyone know how to troubleshoot this? Any help is appreciated.

1 Like

Hey
I don’t have a solution, but you can run the Python script in the terminal

The notebook doesn’t work for me either

Maybe it is an issue with the websocket and the async function

Also, the notebook does not support multiprocessing sometimes

So the asyc is kind of multiprocessing stuff