Keep getting CancelledError

I’m trying to get the Alpaca Momentum Trading Example script to work, and I’ve ironed out most of the issues. But it still randomly (usually after 20-30 minutes) throws an asyncio.exceptions.CancelledError and shuts down.

Since the script needs to run the whole time the market is open, that’s obviously a big problem :slight_smile:
I’m pretty familiar with Python but a total noob at websockets and streaming. Anyone know what’s happening, and how to fix it?

did you figure this out? I am running into the same issue.

Thanks,
Randy

Hi guys, these happen when server communication disconnects.
we handled this by trying to reconnect when it happens in the most updated version of the sdk
install the latest version by running pip install -U alpaca-trade-api

The error is still not fixed. Updated to the latest version but I also keep getting the same error