Momentum-Trading-Example icon indicating copy to clipboard operation
Momentum-Trading-Example copied to clipboard

ALGO.PY: Fatal Python error: Cannot recover from stack overflow.

Open BlueMistTrekker opened this issue 4 years ago • 3 comments

I've read through all the issues and made corrections to algo.py as needed. Now I am getting:

Fatal Python error: Cannot recover from stack overflow. Current thread 0x00007f089df6a740 (most recent call first): File "/usr/lib/python3.7/asyncio/base_events.py", line 480 in _check_closed File "/usr/lib/python3.7/asyncio/base_events.py", line 560 in run_until_complete File "/usr/local/lib/python3.7/dist-packages/alpaca_trade_api/stream2.py", line 275 in run File "algo.py", line 422 in run_ws File "algo.py", line 426 in run_ws File "algo.py", line 426 in run_ws File "algo.py", line 426 in run_ws

BlueMistTrekker avatar Jun 19 '20 14:06 BlueMistTrekker

@BlueMistTrekker - I am running into the same problem. Running the code during trading hours, reduced the symbol list to 10. Let me know if you find a solution. Thanks!

sanzgiri avatar Jun 30 '20 15:06 sanzgiri

@BlueMistTrekker @sanzgiri

Alpaca changed their SDK. The A.{} channel is no longer required. Please see code update below.

channels = ['trade_updates']
for symbol in symbols:
    #symbol_channels = ['A.{}'.format(symbol), 'AM.{}'.format(symbol)]
    symbol_channels = ['AM.{}'.format(symbol)]
    channels += symbol_channels
print('Watching {} symbols.'.format(len(symbols)))
run_ws(conn, channels)

References https://forum.alpaca.markets/t/valueerror-unknown-channel-a-tsla-you-may-need-to-specify-the-right-data-stream/1424

kqinvestor avatar Jul 01 '20 19:07 kqinvestor

Hi @kqinvestor,

I tried making the change you suggested. But I still get the same error:

Other things I have tried:

  • Reduced the number of symbols to a very small number (6)
  • Tried data_stream settings of "polygon" as well as "alpacadatav1" for StreamConn
  • Initially was running this on a Mac, but getting same error on GCP in an environment set up described in the blog post.

The code will start "Watching xxx symbols" for several minutes, no other output and eventually I get a long stream of "Event loop is closed" messages and then the fatal python error.

Note this is all with the paper trading api.

Thanks, Ashutosh

sanzgiri avatar Jul 02 '20 16:07 sanzgiri