Open zacciep opened 6 days ago
hey @zacciep thanks for reporting this. So when I was testing this API out, I noticed it returning errors when I attempted to submit more than order. Admittedly, I haven't tried bracket orders, just multiple independent ones.
Have you used this endpoint successfully submitting bracket orders? If that is the case, then indeed it would make sense to expand this functionality.
Yes, I have successfully submitted bracket orders. I recall some comment on the docs pages about not submitting independent orders in bulk as well. But bracket orders (or orders with parent order dependency) seem to work.
Ahh many thanks for clarifying this. I wondered why they allow multiple orders to be submitted but then it never worked. I'll try to find some time to incorporate that into IBind 👍
Okay, seems I found some time right away. I think I managed to figure it out pretty fast. This looks correct?
Try pip install ibind==0.1.4rc1
in order to see if it works for you. I've added the rest_07_bracket_orders.py
example which should submit a bracket order.
The current implementation of
place_order()
does not allow a list of orders. However, a list of orders is supported by the gateway (and documented on IBKR (https://ibkrcampus.com/ibkr-api-page/cpapi-v1/#bracket-orders). This is needed to support simultaneous bracket order submission (a parent order with a profit take and stop loss).Removing the constraint and a small modification to the order handling allows a list of orders:
place_order()
- line 121# if isinstance(order_request, list):
# raise RuntimeError(f'IbkrClient.submit_order() does not accept a list of orders, found: {order_request}')
if not isinstance(order_request, list):
order_request = [order_request]
handle_questions()
also needs updating to supress complaints about multiple order returns during question handling.handle_questions()
- line 219# if len(data) != 1:
# _LOGGER.warning(f'While handling questions multiple orders were returned: {pprint.pformat(data)}')