IB and get_orders_open
-
Is there a way to pull in open orders from IB?
If I enter an order to IB and then my program crashes, when I reconnect, the order is still sitting in my IB orderbook, but no orders available in the software via self.order. This leaves me powerless to cancel the order via software.
self.broker does not seem to have get_orders_open() method available.
Is it possible?
(Pdb) [print(func) for func in dir(self.broker) if not func.startswith('_')] BrokerBase CANCELLED FILLED IBBroker INACTIVE PENDINGCANCEL PENDINGSUBMIT PRESUBMITTED SUBMITTED add_order_history addcommissioninfo buy cancel cash cerebro comminfo executions frompackages fundmode fundshares fundvalue get_fundmode get_fundshares get_fundvalue get_notification getcash getcommissioninfo getposition getvalue ib init next notifs notify orderbyid orderstatus ordstatus p packages params push_commissionreport push_execution push_ordererror push_orderstate push_orderstatus push_portupdate sell set_fund_history set_fundmode setcommission start startingcash startingvalue stop submit tonotify value
-
No, there isn't. backtrader isn't conceived as a manager of your account. You could keep the IB reference of orders you have created in your preferred form of storage and check it against the incoming order to discard it if needed.
You probably want to check/store these two fields:
m_clientId
: which client created the order (you may have other clients connecting to the API)m_permId:
the host order identifier
-
@backtrader Would you consider adding such an API method in the future? This would be very useful feature for live trading.