How to get order id in holding or position

mastertrader21
I had placed the order in system & get the order id & now want to map the holding & position data with order id but I dont getting the order order in holding or position api. How to manage the same
  • sujith
    Can you elaborate why you are trying to do that? Maybe we can look for alternative.
  • sauravkedia
    sauravkedia edited October 2017
    @sujit, I have the same question.
    I am running multiple positional strategies and I want to know which position (or holding) is coming from which strategy. Plus I trade manually as well. So, right now its bit of a headache.

  • sujith
    @sauravkedia,
    Even we don't get to know the corresponding order id for a position.
    I am afraid, it is not possible to link positions and orders.
  • mastertrader21
    Ok how to differentiate whether the holding or position is of which type i.e its BUY or SELL type
  • sujith
    @mastertrader21,
    In positions, if the quantity is greater than 0 then it is a long position, if it is less than 0 then it is a short position.
    Holdings will always have quantity as 0 or greater than 0.
  • revendar
    @sauravkedia If there is no map of order-position, how do you achieve trailing sl?
    Why not keep a key like stock_exp_pos_qty ?
  • sauravkedia
    @revendar , I work reverse. The strategies are aware of the positions they are carrying (by tracking tracking tags at fills at Zerodha ). Thats it. I don't really breakdown positions/holdings as seen on zerodha and match them with the my system derived positions across strategies. But then, while it is working, I am not happy with the state of affairs as there is a scope of error here. For example, a missed corporate action may just send it haywire.

    Between, I would want to know what your idea around "key like stock_exp_pos_qty".
  • ramatius
    It is not so difficult to link the strategy/position/order-id, if you take care of linking them together at the time of firing the order. Note that the order API returns the order ID, which can then be associated with the particular position in a particular algo from which the order came. For example, pls see the table below, where user, algo and order id lists are shown,


  • sauravkedia
    sauravkedia edited November 2017
    @ramatius thats what I am doing right now. However, it is not fool proof. Ideally positions across strategies should add up to Zerodha's positions but many things can go wrong example a corporate action. It would have been better had Zerodha given positions as per order_ids.
  • revendar
    @sauravkedia What I meant here 'stock_exp_pos_qty' is you can generate an internal id to identify your trade which will be a combination of strategy+stock+(BUY/SELL)+qty. Incase of corporate action, you will be left with some extra qty in some positions. In case of a spilit, zerodha will send past data in non split adjusted format and your strat will blow up anyways. Does zerodha gives any API for corporate notifications, which we can store and check in market starting to adjust our data internally. I know NSE has some notifications.
Sign In or Register to comment.