How to handle split order in Zerodha API

raaxus
raaxus edited September 2020 in General
@sujith

Hi,

I am coding a complex strategy using Zerodha API, for successful implementation few critical things needs to be handled.

In situations, an order can be split into multiple orders speciality for BO and CO orders and for MIS orders as well (please correct me, if my understanding is wrong here) . Even BO are not enabled right now, still i need to code for BO as well for future.

I have few doubts in this regards.
1. Can you please suggest how can i link all split orders to its main order? with example explanation would be highly appreciated.

2. If possible, please share some sample json for order book / trade book where order got splitted.

3. To check the actual quantity executed till now, can i rely on Filled Quantity from Order Book?

4. Filled Quantity received on Order Updated (from socket) would be the final quantity or it is a incremental quantity?

Thanks,
  • sujith
    In the case of bracket or cover orders, there is a field called parent order id which can be used to find the group of the order. In case, you are doing MIS order then you can make use of the tag parameter while placing an order.
    You can checkout the json example and explaination for response attributes here.

    Yes, you can rely on the filled quantity in the orderbook to check the executed quantity.

    A filled quantity in the order update will be the cumulative value meaning it will show quantity executed till that point in time.
  • raaxus
    @sujith

    Thanks for your prompt response and clarifications.

    Regarding parent Order ID, i used to attach child orders with its parent order. I hope in case of a split there should be another set of orders example in case BO there would be another 3 orders.

    Please suggest how i can care these conditions, means same time i need to check main order, their child orders and of course their split orders.

    Thanks,
  • sujith
    If you fetch orderbook and look for all the orders with parent order id then you will get all orders right?
    It won't matter if there are four second leg orders or six second leg orders.
  • sujith
    Another one extra will be the parent order.
  • raaxus
    So, in this case, if i cancel any of child order, then it will automatically exit the whole chain related to that particular main order, am i right?
  • sujith
    It is basically an exit order which uses the same cancel order API with parent order id.
    If you don't send a parent order id then API will cancel it as a normal order and you will be in trouble end of the day since RMS looks at it as a hanging position they will close the position by placing another MIS order and then you will be charged for that.
  • raaxus
    @sujith

    Hi,

    In case of BO order, 2 child orders would be created.

    Can you please suggest best way to know which one is Target Order and which one is Stop loss Order?

    Thanks,
  • sujith
    The target order is limit and the stoploss order is SL, but you may also need to note that once the trigger is hit the stop-loss order also becomes LIMIT type. In that case, you need to look at the price and decide.
Sign In or Register to comment.