-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event loop is already running and websocket question #126
Comments
The API URL for a direct connection is the same, just with https:// replaced with wss://. I.e.,
Replace the Xs with your API keys and pass with whatever code you want to handle them. If you have trouble connecting in this way, please reopen the issue and let us know more - copy the full error output if possible. |
Hello, I tried running this and it started spamming 'ERROR:root:error while consuming ws messages: server rejected WebSocket connection: HTTP 429', and every 3 it said, 'ERROR:root:error while consuming ws messages: Error while connecting to wss://data.alpaca.markets/stream:your connection is rejected while another connection is open under the same account'. So now I am trying to figure out how to terminate that connection. This happened when I clicked disconnect instead of terminate. |
Hi, what do you mean "clicked disconnect" where did you click? |
Ok, let me explain in more detail. I use a IDE called PyCharm, and when you stop a program in PyCharm you have 2 options. You can either disconnect from the program, or terminate the program. The main difference is disconnection is where it is still running on your computer, but PyCharm is no longer hosting the program, and terminate is where you stop the program. |
so you need to kill the python process running this code. you can't have more than one connection to the websocket, this is why you get this error. |
@ttt733 Are you able to assist with the momentum template? I just ran into this same error. |
Hello, I am trying to run the code example that trades on slight moves in the bid/ask spread, posted here on github.
Using alpaca_trade_api StreamConn object, I get a runtime error "This event loop is already running"
I have also tried directly connecting to the alpaca api just using the websockets library but I need a wss: url and alpaca only provides the https .../stream address.
can someone help and/or point me to a good source/tutorial for establishing multiple websockets and asyncio?
I have a polygon account for streaming data and I can simply connect to that as a websocket but I want to use the alpaca stream 'trade_updates' as well.
The text was updated successfully, but these errors were encountered: