At times it may so happen that i fire a BO order with my expected ticks tolerance, which need not be sure for a guaranteed execution, however keeping that naked un executed orders would be even riskier when price retracement / reversal happens sometime later, In this case having an exception handling of Placed BO orders would makes more significant.
Let's take a scenario. My open placed order which is expected to executed within N ticks tolerance(defined by me), But in reality my Placed BO order is still open and my ASK price and LTP Jumped far away, then i want my open un executed order to get cancelled if not filled within a N seconds (defined by me)..which I see the best way of exception handling.
Appreciate if could you Pls advise a way how I can achieve the same
KiteNet is a exhaustive library. It can be tweaked to suit anyone's requirements. Virtually everything is possible.
For your requirement you can simple do as below;
Assuming you placed your BO entry order with some tag and want to cancel that order if it not fulfilled in 30 secs.
Cell1 - Get the BO order id using GetOrderCTag Cell2 - Get the order status - GetOrderStatus Cell3 - Get the order time i.e when your order is placed - GetOrderTime Cell4 - Get current system time - Now() Cell5 - Get the time elasped since order time in seconds. =(Cell4 - Cell3)*86400. Cell6 - Cancel Order - IF(Cell5 > 30 AND Cell2="OPEN",CancelOrder,"")
The above is simplest way to do that at formula level. But as a developer, you can wrap those in a UDF to make more convenient.
Please note, Ensure your system time is up to date and set to IST else time difference may go wrong as Order Time is IST. Use static variables to prevent multiple cancellation request. Use unique tag to place order like TrdSymbol + Your Stgy Identifier + Signal.
P.S. When you done some work (Code) on the above, pls share it in the forum, so that others will also get benefited.
KiteNet is a exhaustive library.
It can be tweaked to suit anyone's requirements.
Virtually everything is possible.
For your requirement you can simple do as below;
Assuming you placed your BO entry order with some tag and
want to cancel that order if it not fulfilled in 30 secs.
Cell1 - Get the BO order id using GetOrderCTag
Cell2 - Get the order status - GetOrderStatus
Cell3 - Get the order time i.e when your order is placed - GetOrderTime
Cell4 - Get current system time - Now()
Cell5 - Get the time elasped since order time in seconds. =(Cell4 - Cell3)*86400.
Cell6 - Cancel Order - IF(Cell5 > 30 AND Cell2="OPEN",CancelOrder,"")
The above is simplest way to do that at formula level.
But as a developer, you can wrap those in a UDF to make more convenient.
Please note,
Ensure your system time is up to date and set to IST else time difference may go wrong as Order Time is IST.
Use static variables to prevent multiple cancellation request.
Use unique tag to place order like TrdSymbol + Your Stgy Identifier + Signal.
P.S.
When you done some work (Code) on the above, pls share it in the forum, so that others will also get benefited.
Here is the
Code in Action