How to perform auto square off in afternoon for order placed in morning.

hardikdesai
hardikdesai edited February 2018 in Java client
@sujith : I want to auto square off my order in afternoon at 3:15. I tried using cancelOrder method passing the order id which i got when i placed my order in morning. The square off order should be placed only if the stop loss or target has not been triggered. Can you suggest how can i achieve this?
  • MAG
    This is a programming logic issue.
    Are you placing a bracket order or or are you entering a specific stop loss order once your entry is executed? The logic would vary depending on the answer.

    You could put a tag on all related orders and then write your own custom logic. The flow would be something like this
    • Come up with a tag schema that makes sense to you. It could be something as simple as DDMM1, DDMM2, DDMM3 etc
    • Whenever you place orders, tag all related orders with the same tag.
    • At 3:15 fetch all orders
    • Then sort out the ones matching each tag and then if the stoploss and target for that tag is not triggered, place an exit order and cancel the other related orders.
    Depending on what kind of a system you are using or building, you could extend this further.
Sign In or Register to comment.