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

subscription for more than 1 data channel can fail #5

Open
KlausGlueckert opened this issue Jan 29, 2021 · 1 comment
Open

subscription for more than 1 data channel can fail #5

KlausGlueckert opened this issue Jan 29, 2021 · 1 comment

Comments

@KlausGlueckert
Copy link

KlausGlueckert commented Jan 29, 2021

In this case I am subscribing to 'alpacadatav1/AM.TSLA' and then 'alpacadatav1/AM.SPY.

Appereantly you await conn.unsubscribe(previous_channels) when adding additional subscriptions and then re-subscribe.
This process doesnt work and fails in the trade api part, because the self._ws part is None

2021-02-01 01:27:10,493 root Alpaca Proxy Agent v0.5.5
2021-02-01 01:27:10,493 root Using the Alpaca Websocket
< {'action': 'authenticate', 'data': {'key_id': 'PKMIAA7DFADUGOKNIGUR', 'secret_key': '98xk2nDUq6QswX9fAuN3Mj4ZLLUI7ptFrVCzTCtc'}}
< {'action': 'listen', 'data': {'streams': ['alpacadatav1/AM.TSLA']}}
previous channels []
new_channels ['alpacadatav1/AM.TSLA']
< {'action': 'authenticate', 'data': {'key_id': 'PKMIAA7DFADUGOKNIGUR', 'secret_key': '98xk2nDUq6QswX9fAuN3Mj4ZLLUI7ptFrVCzTCtc'}}
< {'action': 'listen', 'data': {'streams': ['alpacadatav1/AM.SPY']}}
previous channels ['alpacadatav1/AM.TSLA']
new_channels ['alpacadatav1/AM.SPY']
Traceback (most recent call last):
  File "main.py", line 169, in serve
    await conn.unsubscribe(previous_channels)
  File "/usr/local/lib/python3.6/site-packages/alpaca_trade_api/stream2.py", line 278, in unsubscribe
    await self.data_ws.unsubscribe(data_channels)
  File "/usr/local/lib/python3.6/site-packages/alpaca_trade_api/stream2.py", line 121, in unsubscribe
    await self._ws.send(json.dumps({
AttributeError: 'NoneType' object has no attribute 'send'

Done
2021-02-01 01:28:18,987 root connected to: wss://data.alpaca.markets/stream
@KlausGlueckert KlausGlueckert changed the title subscription works, but no data received sometimes subscription for more than 2 data objects can fail - conn object is None Feb 1, 2021
@KlausGlueckert KlausGlueckert changed the title subscription for more than 2 data objects can fail - conn object is None subscription for more than 1 data object can fail - conn object is None Feb 1, 2021
@KlausGlueckert KlausGlueckert changed the title subscription for more than 1 data object can fail - conn object is None subscription for more than 1 data channel can fail - conn object is None Feb 1, 2021
@KlausGlueckert KlausGlueckert changed the title subscription for more than 1 data channel can fail - conn object is None subscription for more than 1 data channel can fail Feb 1, 2021
@camelpac
Copy link
Owner

camelpac commented Aug 7, 2021

Hi, there's a new release for this project.
if this is still an issue, please let me know

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

2 participants