erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.81k stars 754 forks source link

Exception when TWS disconnects clients #77

Closed semigodking closed 6 years ago

semigodking commented 6 years ago

The following exception occurs when TWS disconnects clients.

2018-07-14 17:38:22 root INFO REQUEST reqRealTimeBars {'realTimeBarsOptions': None, 'useRTH': False, 'whatToShow': 'TRADES', 'barSize': 5, 'contract': Contract(secType='FUT', symbol='CL', lastTradeDateOrContractMonth='201808', exchange='NYMEX'), 'reqId': 5}
2018-07-14 17:38:22 root INFO ANSWER marketDataType {'marketDataType': 1, 'reqId': 3}
2018-07-14 17:48:52 ib_insync.wrapper ERROR Error 317, reqId 4: Market depth data has been RESET. Please empty deep book contents before applying any new entries., contract: Contract(secType='FUT', symbol='CL', lastTradeDateOrContractMonth='201808', exchange='NYMEX')
2018-07-14 17:48:52 ib_insync.client ERROR Decode failed
Traceback (most recent call last):
  File "/home/ubuntu/venv/lib/python3.6/site-packages/ib_insync/client.py", line 251, in _onSocketHasData
    self._decode(fields)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/ib_insync/client.py", line 347, in _decode
    self.decoder.interpret(fields)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/ibapi/decoder.py", line 1345, in interpret
    self.interpretWithSignature(fields, handleInfo)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/ibapi/decoder.py", line 1326, in interpretWithSignature
    method(*args)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/ib_insync/wrapper.py", line 883, in error
    for position in reversed(range(l)):
TypeError: 'list' object cannot be interpreted as an integer
2018-07-14 17:48:52 ib_insync.client ERROR Peer closed connection
erdewit commented 6 years ago

Thanks for the bug report. This is now fixed in the new version 0.9.27.