Hi @sujith , I have a scenario like, 1) Placed 2 different orders at price x with y target 2) Both orders are executed. Now, i want to check if any one out these positions is closed then i want to close other position too. So how can i check if position is open or closed
Hi @llpach, Once you place an order you get order_id after the request is successful. Fetch orderbook and check the status of both orders, if the status of one of the orders is rejected then fetch positions, find the corresponding position which will have the same tradingsymbol and product and then place a market order with opposite transaction_type.
PS: If an order is rejected then there won't be an entry in positions table.
Hi @llpach, You can find the order with parent order id same as the id what you get after placing an order. Once you get second leg orders, you can cancel one of the child order like this.
A closed position will have netQuantity = 0.
Can you elaborate on your scenario so that we can give more specific answer?
I have a scenario like,
1) Placed 2 different orders at price x with y target
2) Both orders are executed. Now, i want to check if any one out these positions is closed then i want to close other position too.
So how can i check if position is open or closed
Once you place an order you get order_id after the request is successful.
Fetch orderbook and check the status of both orders, if the status of one of the orders is rejected then fetch positions, find the corresponding position which will have the same tradingsymbol and product and then place a market order with opposite transaction_type.
PS: If an order is rejected then there won't be an entry in positions table.
You can find the order with parent order id same as the id what you get after placing an order.
Once you get second leg orders, you can cancel one of the child order like this.