WebSocket w/ Python API Not Opening/Streaming?

I’m using the code available from a tutorial at https://github.com/hackingthemarkets/alpaca-market-data-streaming-api but I can only see that the connection was closed and I can’t see that it was ever opened or that anything was streamed. Using the command line with direct json works for me but it doesn’t work for me with Python for some reason. Anyone have any guesses why? For context, when I run the exact code with my API keys in the config file, I only see the “closed connection” statement printed and nothing else happens.

1 Like

Same problem. Can someone please help?

Hi, try using this example: https://github.com/alpacahq/alpaca-trade-api-python/blob/add_simple_stream_example/examples/websocket_example.py

Thanks for responding @Shlomik ! But after I ran the code, my computer kept displaying, “error while consuming ws messages: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123).” Do you know how to fix this?

Hi, seems like something wrong with you certificate configurations. don’t think it’s related to the code you used.
if you are using mac os I’ve seen some issues about that on stackoverflow. you should search there.

I tired one of the program for live quote. I need to use my live Key rather than paper Key. and then it works for me