Skip to content
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

multiple_data_strategy.py throwing exception: your connection is rejected #55

Closed
William-Ebertz opened this issue May 29, 2020 · 5 comments

Comments

@William-Ebertz
Copy link

Hey there,

I'm encountering this issue while running the unmodified multiple_data_strategy.py sample in paper trading mode. I have no other scripts running on the account. This is the exception:

Starting Portfolio Value: 100000.0
Exception in thread Thread-7:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/alpaca_backtrader_api/alpacastore.py", line 483, in _t_streaming_prices
streamer.run()
File "/home/pi/.local/lib/python3.7/site-packages/alpaca_backtrader_api/alpacastore.py", line 132, in run
self.conn.run(channels)
File "/home/pi/.local/lib/python3.7/site-packages/alpaca_trade_api/stream2.py", line 275, in run
loop.run_until_complete(self.subscribe(initial_channels))
File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "/home/pi/.local/lib/python3.7/site-packages/alpaca_trade_api/stream2.py", line 250, in subscribe
await self.data_ws.subscribe(data_channels)
File "/home/pi/.local/lib/python3.7/site-packages/alpaca_trade_api/stream2.py", line 104, in subscribe
await self._ensure_ws()
File "/home/pi/.local/lib/python3.7/site-packages/alpaca_trade_api/stream2.py", line 88, in _ensure_ws
await self._connect()
File "/home/pi/.local/lib/python3.7/site-packages/alpaca_trade_api/stream2.py", line 52, in _connect
raise Exception(f"Error while connecting to {self._endpoint}:"
Exception: Error while connecting to wss://data.alpaca.markets/stream:your connection is rejected while another connection is open under the same account

@William-Ebertz William-Ebertz changed the title multiple_data_.py throwing exception: your connection is rejected multiple_data_strategy.py throwing exception: your connection is rejected May 29, 2020
@shlomiku
Copy link
Contributor

Hi, so working with multiple data is currently an issue.
there's a branch solving this issue but it's not yet perfect.
you could install it and work with it to run this example code.
install it like so:
pip install -U git+https://github.com/alpacahq/alpaca-backtrader-api@shared_websocket_streamer

@William-Ebertz
Copy link
Author

Yeah, the Alpaca API mentioned that they don't support multiple websocket connections, so this looks like a good workaround. I'll try it out, thanks.

@alias-noa
Copy link

Are you guys talking about running it on multiple tickers?

@shlomiku
Copy link
Contributor

yes

@William-Ebertz
Copy link
Author

Thanks, this got backtesting up and running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants