Cancelling or modifying partially executed Iceberg orders

psai1990
psai1990 edited April 2023 in General
Zerodha's documentation says:

If any leg of an Iceberg is cancelled, all the remaining pending legs that are yet to be placed will be automatically cancelled. Similarly, if the price of any leg of the Iceberg is modified, the new price will automatically be applied to all the pending legs.
As far as I understand, once the first leg (parent order) of an iceberg order is executed, its state is changed to COMPLETE, and immediately the second leg's order will placed into the market. The second leg's orderId will be available in the orderbook only after the first leg's order reaches COMPLETE status, and so on.
Am I correct?

Does the documentation mean that I can still use the parent orderId directly in the API to cancel or modify the remaining pending legs, even when the parent order's status is COMPLETE?
If not, is there any recommended way to get the orderId of the currently open pending leg?
  • psai1990
    @rakeshr
    @Kailash
    Can you please clarify
  • rakeshr
    once the first leg (parent order) of an iceberg order is executed, its state is changed to COMPLETE, and immediately the second leg's order will placed into the market.
    The second leg's orderId will be available in the orderbook only after the first leg's order reaches COMPLETE status
    Yes, every subsequent leg will be executed only once the previous leg is executed.
    I can still use the parent orderId directly in the API to cancel or modify the remaining pending legs, even when the parent order's status is COMPLETE?
    Yes, if the legs are pending you can use modify_order call with the required parent_order_id, variety, etc to modify the price.
    If not, is there any recommended way to get the orderId of the currently open pending leg?
    Yes, it will be in the open orderbook.
  • psai1990
    psai1990 edited April 2023
    @rakeshr
    Thanks for the response.

    Yes, if the legs are pending you can use modify_order call with the required parent_order_id, variety, etc to modify the price.
    I could finally test this on an illiquid stock option. I observed that I am not able to cancel the remaining iceberg legs with the parent_order_id, once the first iceberg leg is executed (i.e., when the status of parent orderId is changed to COMPLETE)
    I used the right variety "iceberg" while hitting the cancellation API. However, I get error response with the following message: "Order cannot be cancelled as it is being processed. Try later."

    I am able to cancel only with the new order_id of the current leg that is open.

    Please verify and confirm if I am missing something?
Sign In or Register to comment.