How to get Child orders from postback URL

quicksilverm
Hi, I have placed an order and the postback url is giving me the data for the parent order. However, how do i get the data for the child orders as my order is a BO and is multilegged. Here are the values:
Order id for the order placed successfully 170227000343189. If i do a getOrder() for this order id in my java code. i get the following response

order.orders.get(i).orderId : order.orders.get(i).parentOrderId : status
170227000343189 : null : COMPLETE
170227000343189 : null : OPEN
170227000343189 :null : OPEN
170227000343189 :null : OPEN
170227000343189 :null : OPEN PENDING
170227000343189 :null : VALIDATION PENDING
170227000343189 :null : PUT ORDER REQ RECEIVED

WHY do i get child order id for all the items same as parent order id?

The postback URL gives:
[order_id=170227000343189, exchange_order_id=1100000002628069,
placed_by=ZW2900, status=COMPLETE, status_message=, tradingsymbol=HINDALCO,
exchange=NSE, order_type=LIMIT, transaction_type=SELL,
validity=DAY, product=BO, average_price=180.8, price=180.8,
quantity=100, filled_quantity=100, unfilled_quantity=0,
trigger_price=0.0, order_timestamp=2017-02-27 13:14:49,
exchange_timestamp=27-Feb-2017 13:14:49, checksum=8e577f0acec3ca092e098046c9af3bc736bfc8e12361d93478b190d89ada1c21]



  • sujith
    Hi @quicksilverm,
    1. getOrder(order_id) will give you lifecycle of an order in the system. As you can see all states it has gone through till it has reached complete status.
    2. You need to fetch orderbook after BO first leg completion and filter orders whose parent order id is same as postback order id.
  • quicksilverm
    @sujith For the following suggestion :
    2. You need to fetch orderbook after BO first leg completion and filter orders whose parent order id is same as postback order id.
    How would I be notified that the 1st leg has been completed ? I do have postback URL configured. Would I get the notification there ?

    2. I thought instead of fetching the orderbook ( getOrder() API ) , I would instead run getTrades(orderID) which would tell me about all my individual trades ?

    3. Documentation says that getTrades(orderID) tells about the various legs of the order, but then it doesn't tell me whether the respective trades is a SL-M or LIMIT.....if I need to modify the order based on my algo, I do not know what to co-orelate

    4. If for above point (3), I need to run getOrder()
    Empty Parenthesis
    , then would it solve all my purpose .....to identify which orders are LIMIT and which are SL-M .

    5. If getOrder() is what it takes, then what is the purpose of getTrade(OrderId). Is there a value in having this call. Perhaps I am missing out on something which is confusing me

  • quicksilverm
    @sujith @Kailash
    Let me a bit more clear so that you can precisely answer my query. Also do try to answer my above mentioned queries as well.

    My order flow is this -
    1. I place a BO from my algo. Order order = zerodha.placeorder(myOrder) where myorder.quantity=10000
    2. I get parentID which is nothing but order.orderID from above.
    3. My quantity is huge so it would be creating multi-leg order.
    4. I have postback URL configured which would notify me when the order gets placed.
    Would the postback URI also notify when the order gets cancelled or exited or executed, when it reaches it's target ?
    5. Presuming that the order for 10000 stocks got executed, I would imagine there would be couple of pairs of (LIMIT<==>SL-M) ( OPEN==PENDING) state
    6. As the stock goes up, I would like to modify my target and for this I believe I need to modify each of the individual legs. I need a child_order_id to achieve this.....
    Which API would work for me here ? I didn't want to run getOrder() since if there are a lot of trades in a day then this will be quite bulky....isn't it ?
    7. I thought getTrades(orderID) would just fetch me everything for only that order, but then I don't think it gives any pending or open orders and seems to only focus on EXECUTED trades,
    8. I would like to fetch the childOrders in the most effecient manner given a parent_ORDER_ID. What is the best way to achieve this.
  • sujith
    @quicksilverm,
    How would I be notified that the 1st leg has been completed ? I do have postback URL configured. Would I get the notification there ?
    Yes, you will get postback after the first leg is executed.

    getTrades(order_id) will give you a list of trades that happened for the given order id which will not contain any details about child orders.

    The only feasible solution for this is to fetch orderbook(getOrder()) and check for pending orders with parent order id same as postback order id.
    You can check order type field to know whether it is limit or stoploss order.
    How would I be notified that the 1st leg has been completed ? I do have postback URL configured. Would I get the notification there ?
    Ideally, you must get postback but as of now because of some bug, you will not be receiving postback for the second leg execution. We are working on fixing this issue.
  • quicksilverm
    @sujith @Kailash
    Let me a bit more clear so that you can precisely answer my query. Also do try to answer my above mentioned queries as well.

    My order flow is this -
    1. I place a BO from my algo. Order order = zerodha.placeorder(myOrder) where myorder.quantity=10000
    2. I get parentID which is nothing but order.orderID from above.
    3. My quantity is huge so it would be creating multi-leg order.
    4. I have postback URL configured which would notify me when the order gets placed.
    Would the postback URI also notify when the order gets cancelled or exited or executed, when it reaches it's target ?
    5. Presuming that the order for 10000 stocks got executed, I would imagine there would be couple of pairs of (LIMIT<==>SL-M) ( OPEN==PENDING) state
    6. As the stock goes up, I would like to modify my target and for this I believe I need to modify each of the individual legs. I need a child_order_id to achieve this.....
    Which API would work for me here ? I didn't want to run getOrder() since if there are a lot of trades in a day then this will be quite bulky....isn't it ?
    7. I thought getTrades(orderID) would just fetch me everything for only that order, but then I don't think it gives any pending or open orders and seems to only focus on EXECUTED trades,
    8. I would like to fetch the childOrders in the most effecient manner given a parent_ORDER_ID. What is the best way to achieve this.
  • quicksilverm
    @sujith @Kailash
    Let me a bit more clear so that you can precisely answer my query. Also do try to answer my above mentioned queries as well.

    My order flow is this -
    1. I place a BO from my algo. Order order = zerodha.placeorder(myOrder) where myorder.quantity=10000
    2. I get parentID which is nothing but order.orderID from above.
    3. My quantity is huge so it would be creating multi-leg order.
    4. I have postback URL configured which would notify me when the order gets placed.
    Would the postback URI also notify when the order gets cancelled or exited or executed, when it reaches it's target ?
    5. Presuming that the order for 10000 stocks got executed, I would imagine there would be couple of pairs of (LIMIT<==>SL-M) ( OPEN==PENDING) state
    6. As the stock goes up, I would like to modify my target and for this I believe I need to modify each of the individual legs. I need a child_order_id to achieve this.....
    Which API would work for me here ? I didn't want to run getOrder() since if there are a lot of trades in a day then this will be quite bulky....isn't it ?
    7. I thought getTrades(orderID) would just fetch me everything for only that order, but then I don't think it gives any pending or open orders and seems to only focus on EXECUTED trades,
    8. I would like to fetch the childOrders in the most effecient manner given a parent_ORDER_ID. What is the best way to achieve this.
Sign In or Register to comment.