When i call GetPositions its always giving me value 10 -15 second old data. For ex In Terminal PNL is 100 at (10:20) but through API getting 100 at (10:25)
Hi @sujith One more thing when i place Cover order and the time when it gets executed successfully, it places one more order for stoploss. How can i get order id of that order and how to exit that order.
If you place a cover order with entry type market then it will be filled immediately. If you place a limit type cover order then it gets filled according to the availability of counterparty. In both the cases, the stop-loss order is placed immediately when you place the first leg order. Once you place a cover order, for successful placement you will get order id in the response which is the parent order id for the second leg order. In order to fetch second leg order, you need to fetch orderbook and look order with parent order id same as first order id.
It is not recommended to poll positions for updated P&L. You need to calculate that at your end using this formula
One more thing when i place Cover order and the time when it gets executed successfully, it places one more order for stoploss. How can i get order id of that order and how to exit that order.
In both the cases, the stop-loss order is placed immediately when you place the first leg order.
Once you place a cover order, for successful placement you will get order id in the response which is the parent order id for the second leg order.
In order to fetch second leg order, you need to fetch orderbook and look order with parent order id same as first order id.