I would like to close the positions based on the ongoing profit and loss of the positions. Is it possible to retrieve the profit/loss data through websocket streaming or else I would need to continuously call any API to check live profit and losses for each order? Please share relevant information along with best practices to follow and code samples, if any.
I'm planning to execute a market orders, and I have a question regarding the process. Do I need to retrieve the average order price before calculating the PnL using the provided formula:
Additionally, could you clarify when I should check the market price at which the orders are placed? Is it after sending each order, or at a specific point in the workflow? Please help.
Hello @sujith, I have one more question please to wrap up this thread:
When it comes to exiting a position at a specific profit or loss, what would be the recommended approach between the following two options?
1) Upon placing the order, saving the average_price field from the response and then exiting at profit or loss amount based on the formula you shared.
2) Upon placing the order, saving the average_price field from the response and calculating the exit stock prices based on a specific percentage of profit or loss in the script. Then, send the exit order at the calculated stop loss or take profit stock price.
Additionally, in such an approach, which types of orders are typically preferred for exiting: market or limit orders?
There will be one consolidated position created for an instrument and particular product type. You can see whatever fits your purpose. I would suggest using Kite web once to know the behavior of the platform.
You can refer to this thread to know more about the formula.
I'm going to place market order hence I would also need to average price first before calculating PnL with formula you provided?
pnl = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);
Also, when exactly I need to check the market price at which orders are placed? After sending each order?
I'm planning to execute a market orders, and I have a question regarding the process. Do I need to retrieve the average order price before calculating the PnL using the provided formula:
pnl = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);
Additionally, could you clarify when I should check the market price at which the orders are placed? Is it after sending each order, or at a specific point in the workflow? Please help.
average_price
field of the positions response.When it comes to exiting a position at a specific profit or loss, what would be the recommended approach between the following two options?
1) Upon placing the order, saving the average_price field from the response and then exiting at profit or loss amount based on the formula you shared.
2) Upon placing the order, saving the average_price field from the response and calculating the exit stock prices based on a specific percentage of profit or loss in the script. Then, send the exit order at the calculated stop loss or take profit stock price.
Additionally, in such an approach, which types of orders are typically preferred for exiting: market or limit orders?