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

TypeError: unhashable type: 'list' #10

Open
PushHandle opened this issue Jan 9, 2020 · 1 comment
Open

TypeError: unhashable type: 'list' #10

PushHandle opened this issue Jan 9, 2020 · 1 comment

Comments

@PushHandle
Copy link

PushHandle commented Jan 9, 2020

I have been getting this error consistently at the end of each day while it is trying to liquidate the day's remaining positions. Any thoughts?

Log below:

Jan 08 12:45:10 alpaca-momentum app/worker.1 Trading over, liquidating remaining position in FVE
Jan 08 12:45:10 alpaca-momentum app/worker.1 Task exception was never retrieved
Jan 08 12:45:10 alpaca-momentum app/worker.1 future: <Task finished coro=<StreamConn._consume_msg() done, defined at /app/.heroku/python/lib/python3.6/site-packages/alpaca_trade_api/polygon/streamconn.py:99> exception=TypeError("unhashable type: 'list'",)>
Jan 08 12:45:10 alpaca-momentum app/worker.1 Traceback (most recent call last):
Jan 08 12:45:10 alpaca-momentum app/worker.1 File "/app/.heroku/python/lib/python3.6/site-packages/alpaca_trade_api/polygon/streamconn.py", line 103, in _consume_msg
Jan 08 12:45:10 alpaca-momentum app/worker.1 await self._dispatch(data)
Jan 08 12:45:10 alpaca-momentum app/worker.1 File "/app/.heroku/python/lib/python3.6/site-packages/alpaca_trade_api/polygon/streamconn.py", line 240, in _dispatch
Jan 08 12:45:10 alpaca-momentum app/worker.1 await handler(self, channel, ent)
Jan 08 12:45:10 alpaca-momentum app/worker.1 File "algo.py", line 336, in handle_second_bar
Jan 08 12:45:10 alpaca-momentum app/worker.1 'AM.{}'.format(symbol)
Jan 08 12:45:10 alpaca-momentum app/worker.1 File "/app/.heroku/python/lib/python3.6/site-packages/alpaca_trade_api/polygon/streamconn.py", line 253, in deregister
Jan 08 12:45:10 alpaca-momentum app/worker.1 self._handler_symbols.pop(self._handlers[channel_pat], None)
Jan 08 12:45:10 alpaca-momentum app/worker.1 TypeError: unhashable type: 'list'
Jan 08 14:04:26 alpaca-momentum heroku/worker.1 State changed from up to down
Jan 08 14:04:28 alpaca-momentum heroku/worker.1 Stopping all processes with SIGTERM
Jan 08 14:04:28 alpaca-momentum heroku/worker.1 Process exited with status 143

@sylvanosullivan
Copy link

I haven't spun this up yet, so I can't say for sure.
However, I can say that:
self._handlers in alpaca_trade_api/polygon/streamconn.py is a dictionary. Attempting to use a list as a key to a dictionary results in this error. We see where this could happen in the pattern (self._handlers[channel_pat], None), if channel_pat is a list.
It looks like lines 333-336 in algo.py always pass a list as the argument to streamconn.deregister():
conn.deregister([ 'A.{}'.format(symbol), 'AM.{}'.format(symbol) ])

so this error should always occur.

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