diff --git a/piker/brokers/ib/broker.py b/piker/brokers/ib/broker.py index b78f2880..f9c27bba 100644 --- a/piker/brokers/ib/broker.py +++ b/piker/brokers/ib/broker.py @@ -1243,32 +1243,47 @@ async def deliver_trade_events( # never relay errors for non-broker related issues # https://interactivebrokers.github.io/tws-api/message_codes.html code: int = err['error_code'] - if code in { - 200, # uhh + reason: str = err['reason'] + reqid: str = str(err['reqid']) + + # "Warning:" msg codes, + # https://interactivebrokers.github.io/tws-api/message_codes.html#warning_codes + # - 2109: 'Outside Regular Trading Hours' + if 'Warning:' in reason: + log.warning( + f'Order-API-warning: {code!r}\n' + f'reqid: {reqid!r}\n' + f'\n' + f'{pformat(err)}\n' + # ^TODO? should we just print the `reason` + # not the full `err`-dict? + ) + continue + + # XXX known special (ignore) cases + elif code in { + 200, # uhh.. ni idea # hist pacing / connectivity 162, 165, - # WARNING codes: - # https://interactivebrokers.github.io/tws-api/message_codes.html#warning_codes - # Attribute 'Outside Regular Trading Hours' is - # " 'ignored based on the order type and - # destination. PlaceOrder is now ' 'being - # processed.', - 2109, - # XXX: lol this isn't even documented.. # 'No market data during competing live session' 1669, }: + log.error( + f'Order-API-error which is non-cancel-causing ?!\n' + f'\n' + f'{pformat(err)}\n' + ) continue - reqid: str = str(err['reqid']) - reason: str = err['reason'] - if err['reqid'] == -1: - log.error(f'TWS external order error:\n{pformat(err)}') + log.error( + f'TWS external order error ??\n' + f'{pformat(err)}\n' + ) flow: dict = dict( flows.get(reqid)