I am reading the Positions and then based on the Buy Price and the LTP deciding whether to sell or not. The 'buy_price' value given by the positions() function is the average of trades in that equity during the day and not the current purchase price in case of multiple trades in the same equity / tradingsymbol.
Is this the intended result? This same value is returned by the field 'day_buy_price' when in fact as per the documentation the 'net' is the actual, current net position portfolio and so the buy_price should be the buy price of the current purchase i.e quantity in hand rather than the average.
How can I get the buy price value of the current lot held in hand ? I can use the orders to get the value, but it would be a circuitous route in the sense that one will have to filter and find the open position, which is otherwise readily available using the positions() functions.
Positions are always an aggregate value for one tradingsymbol of the same product type. It is based on your M2M perspective. We don't have a way to tag orders for a position. It comes like this from the OMS. If it is overnight then it will show up in the net positions. If it is day then it will show up in the day positions array.
You will have to tag orders and use the average price of that to do your stuff.
You will have to tag orders and use the average price of that to do your stuff.