erdewit / ib_insync

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

Error handling fields #611

Closed k3a closed 1 year ago

k3a commented 1 year ago

For some reason ib_insync 0.9.85 started throwing these errors one day. I am not sure what triggered it (which method). Restarting the python script "fixed" the problem.

Creating this issue in case it helps to find a corner case of the decoder or something like that. Feel free to close it if not useful.

ERROR Error handling fields: ['10', '29', 'SPX', 'OPT', '20230714 22:00:00 Europe/Prague', '4325', 'P', 'SMART', 'USD', 'SPXW  230714P04325000', 'SPXW', 'SPXW', '633127624', '0.05', '100', 'ACTIVETIM,AD,ADJUST,ALERT,ALGO,ALLOC,AVGCOST,BASKET,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,DIS,FOK,GAT,GTC,GTD,GTT,HID,ICE,IOC,LIT,LMT,MIT,MKT,MTL,NGCOMB,NONALGO,OCA,OPENCLOSE,PEGMIDVOL,PEGMKTVOL,PEGPRMVOL,PEGSRFVOL,POSTONLY,PRICECHK,REL,RELPCTOFS,RELSTK,RTH,SCALE,SCALERST,SIZECHK,SMARTSTG,SNAPMID,SNAPMKT,SNAPREL,STP,STPLMT,TRAIL,TRAILLIT,TRAILLMT,TRAILMIT,VOLAT,WHATIF', 'SMART,CBOE,IBUSOPT', '1', '416904', 'S&P 500 Stock Index', '', '202307', 'Indices', 'Broad Range Equity Index', '*', 'US/Central', '20230627:1915-20230628:0815;20230628:0830-20230628:1600;20230628:1915-20230629:0815;20230629:0830-20230629:1600;20230629:1915-20230630:0815;20230630:0830-20230630:1600;20230701:CLOSED;20230702:1915-20230703:0815;20230703:0830-20230703:1215;20230703:1915-20230704:1030;20230704:1915-20230705:0815;20230705:0830-20230705:1600', '20230628:0830-20230628:1515;20230629:0830-20230629:1515;20230630:0830-20230630:1515;20230701:CLOSED;20230702:CLOSED;20230703:0830-20230703:1215;20230703:1915-20230704:1030;20230704:1915-20230705:0815;20230705:0830-20230705:1600', '', '', '0', '2', 'SPX', 'IND', '110,110,110', '20230714', '', '1', '1', '1']
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/ib_insync/decoder.py", line 198, in interpret
    handler(fields)
  File "/opt/homebrew/lib/python3.11/site-packages/ib_insync/decoder.py", line 333, in contractDetails
    cd.longName = cd.longName.encode().decode('unicode-escape')
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LookupError: unknown encoding: unicode-escape
erdewit commented 1 year ago

LookupError: unknown encoding: unicode-escape

The 'unicode-escape' encoding should be present in Python. If it's not then there's something fishy with the Python installation.