I am new to this forum. I just want to Square off the open position when the loss equal to or greater than Rs.1000. How to code this using Python. Kindly give me a sample code to continuously check this(while loop) and execute Square off for every newly opened positions. I take only one position at a time. I may have other positions closed. Only the current open position P&L needs to be calculated and squared off based on the above condition.