alpacahq / Momentum-Trading-Example

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

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

Open BlueMistTrekker opened 4 years ago

BlueMistTrekker commented 4 years ago

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

sanzgiri commented 4 years ago

@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!

kqinvestor commented 4 years ago

@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

sanzgiri commented 4 years ago

Hi @kqinvestor,

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

Other things I have tried:

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