alpacahq / Momentum-Trading-Example

An example algorithm for a momentum-based day trading strategy.
657 stars 218 forks source link

ERROR:root:error while consuming ws messages: cannot set a row with mismatched columns #34

Closed msf2105 closed 3 years ago

msf2105 commented 3 years ago

I am getting this error after running the script as soon as it loads all the symbols. It populates one line every 3-5 seconds.

376/399 377/399 378/399 379/399 380/399 381/399 382/399 383/399 384/399 385/399 386/399 387/399 388/399 389/399 390/399 391/399 392/399 393/399 394/399 395/399 396/399 397/399 398/399 399/399 Success. Watching 399 symbols. ERROR:root:error while consuming ws messages: cannot set a row with mismatched columns ERROR:root:error while consuming ws messages: cannot set a row with mismatched columns ERROR:root:error while consuming ws messages: cannot set a row with mismatched columns ERROR:root:error while consuming ws messages: cannot set a row with mismatched columns ERROR:root:error while consuming ws messages: cannot set a row with mismatched columns ERROR:root:error while consuming ws messages: cannot set a row with mismatched columns ERROR:root:error while consuming ws messages: cannot set a row with mismatched columns ERROR:root:error while consuming ws messages: cannot set a row with mismatched columns

when I interrupt the program I get this.

await self._dispatch(data) File "/usr/local/lib/python3.8/dist-packages/alpaca_trade_api/polygon/streamconn.py", line 224, in _dispatch await handler(self, channel, ent) File "algo.py", line 192, in handle_second_bar minute_history[symbol].loc[ts] = new_data File "/usr/local/lib/python3.8/dist-packages/pandas/core/indexing.py", line 692, in setitem iloc._setitem_with_indexer(indexer, value, self.name) File "/usr/local/lib/python3.8/dist-packages/pandas/core/indexing.py", line 1629, in _setitem_with_indexer self._setitem_with_indexer_missing(indexer, value) File "/usr/local/lib/python3.8/dist-packages/pandas/core/indexing.py", line 1918, in _setitem_with_indexer_missing raise ValueError("cannot set a row with mismatched columns") ValueError: cannot set a row with mismatched columns

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "algo.py", line 411, in run(get_tickers(), market_open, market_close) File "algo.py", line 372, in run run_ws(conn, channels) File "algo.py", line 378, in run_ws conn.run(channels) File "/usr/local/lib/python3.8/dist-packages/alpaca_trade_api/stream2.py", line 348, in run loop.run_until_complete(self.close(should_renew)) File "/usr/lib/python3.8/asyncio/base_events.py", line 603, in run_until_complete self.run_forever() File "/usr/lib/python3.8/asyncio/base_events.py", line 570, in run_forever self._run_once() File "/usr/lib/python3.8/asyncio/base_events.py", line 1823, in _run_once event_list = self._selector.select(timeout) File "/usr/lib/python3.8/selectors.py", line 468, in select fd_event_list = self._selector.poll(timeout, max_ev) KeyboardInterrupt

Does anyone have any advice?

algo.txt