Random error while modifying GTT order

sudipto
I am modifying GTT orders based on certain conditions and about 80% of the times it goes through properly. However about in 20% of the orders, I get the following Kite exception when I call the API "kiteConnect.modifyGTT(gtt.id, params);" ---

Kite Exception: InputException
Code: 400
Message: Trigger already met.

These GTTs which are live and can be modified with exactly the same inputs values from Zerodha's main web interface. However they can't be modified by the api however number of times I try with any valid input. I keep getting the same exception even on varying my input. The only way to modify these GTTs is manually through the Zerodha Web interface.
I cannot find any pattern in these errant GTT orders. These GTT orders have been mostly made while placing the order automatically by the system using the Zerodha interface where you can automatically create GTT with stoploss.

Can you please guide what could be going wrong?
  • sudipto
    Additional point if needed to debug ---
    Gtt Id: 277546802
    Gtt Id: 277553832

    These two GTTs are behaving in the manner described. They are active as of now.
  • Nivas
    It seems that the condition you're attempting to modify has already been met.

    When modifying the GTT details, you would have to send the last_price based on the current LTP. Could you please check if you're sending the correct LTP when modifying the GTT?
  • sudipto
    Nivas, this was indeed the case. My assumption was that the LTP was automatically updated in the GTT. So I was retrieving the GTT (as advised) and then copying the LTP from that to make my param. It seems the LTP in the GTT stays at whatever the value was when it was created. Using the latest LTP to make my params solved the problem.
    The error message is misleading. It suggests that the GTT's state has changed from ready to Triggered, which is of course not the case.

    Suggestion: The error message can be improved to something like -- "Trigger price provided in the input is less than the LTP provided in the input, causing the Trigger to be already met"
  • sudipto
    Nivas... an even better API design would be to not take the LTP value as input at all but to check and validate it before the modification (Similar to what is done on the Zerodha website). In not only makes the use of the API simpler but also prevents wrong GTTs to be created. Depending on the user to supply LTP can lead to weird GTTs being created that may not make any sense.
Sign In or Register to comment.