alpaca-backtrader-api icon indicating copy to clipboard operation
alpaca-backtrader-api copied to clipboard

`Fatal error on SSL transport` and `AttributeError: 'NoneType' object has no attribute 'feed_appdata'`

Open Devination opened this issue 5 years ago • 5 comments
trafficstars

Hello, I tried running my strategy live today and got these errors repeating until 9:29:56AM at which point the Strategy's stop function was invoked. I'm not sure why this happened but I adjusted my cron job to wait until market opens before starting next time... maybe that will solve it? I'll have to wait until Monday to find out. In any case, here's my environment and the error messages:

I'm running this on a Raspberry Pi 3b running Raspbian with Python 3.6.2

09:27:17,ERROR,Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x6f666d70>
transport: <_SelectorSocketTransport closing fd=19 read=idle write=<idle, bufsize=0>>
Traceback (most recent call last):
  File "/home/pi/Python-3.6.2/Lib/asyncio/sslproto.py", line 638, in _process_write_backlog
    ssldata, offset = self._sslpipe.feed_appdata(data, offset)
AttributeError: 'NoneType' object has no attribute 'feed_appdata'
09:27:17,ERROR,error while consuming ws messages: 
09:27:20,ERROR,Fatal error on SSL transport

Thanks!

Devination avatar Aug 14 '20 21:08 Devination

Hi, maybe try updating your ssl packages?

shlomiku avatar Aug 16 '20 14:08 shlomiku

After setting the script start time to 9:30AM and upgrading my python's ssl and asyncio modules, I got much less output, just a single error message and then the trader stopped about 40 mins later:

09:30:07,INFO,=== Live Trade Start ===
10:25:55,ERROR,error while consuming ws messages: 
11:04:58,INFO,=== Live Trade Finished ===

I'm going to try converting my strategy to plain Alpaca calls without the backtrader framework and see what happens.

Devination avatar Aug 18 '20 03:08 Devination

you are using v0.49.0? upgrade to 0.49.1. you will get more debugging logs

shlomiku avatar Aug 18 '20 04:08 shlomiku

After upgrading to 0.49.1 I now get this output:

09:30:07,INFO,=== Live Trade Start ===
11:20:50,INFO,connected to: wss://paper-api.alpaca.markets/stream
11:20:50,INFO,connected to: wss://socket.polygon.io/stocks
('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
11:37:19,INFO,=== Live Trade Finished ===

Side-note: I was able rewrite my strategy with the regular Alpaca API and it works as expected so I'll probably continue with that version. In that version, I'm using the REST calls once every minute instead of using streaming data, maybe that has something to do with it?

Devination avatar Aug 20 '20 16:08 Devination

I haven't seen this error yet: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',)) you could work with REST, it's independent route than the websocket stream. I do recommend workign with the stream as described in the READMEs of this project or this one(https://github.com/alpacahq/alpaca-trade-api-python/) they work well, and they are continuously supported and improved.

shlomiku avatar Aug 22 '20 06:08 shlomiku