I save my orders to a dict of pending orders. If I get an error like that I remove it from my pending list. Aside from that you have to figure out why the original order was rejected. Should be in the order statuses or would be printed as an errorEvent.
?
Make sure you have the events setup to help debug
?
self.ib.orderStatusEvent += self.handle_order_status_update
self.ib.execDetailsEvent += self.handle_trade_execution_details
self.ib.errorEvent += lambda reqId, errorCode, errorString, contract: log.error(
f"Error. ReqId: {reqId}, Code: {errorCode}, Msg: {errorString}, Contract: {contract}"
) # This one logs a lot