could not modify order [2022-Aug-08]

raja1sttarde
Hello,

ref: Order ID: 220808100101248

Through the API I placed a LIMIT order at 9:17:01. If the order is not filled in 10 seconds, i automatically send a modify to MARKET order. The order was not filled by 9:17:11 and mod order was sent out. I got;
2022-08-08 09:17:11	bn917	 [ENTRY 220808100101248::OPEN] PE NOT complete, sent MARKET order
2022-08-08 09:17:11 modifyOrder_strat fnc error: Order cannot be modified as it is being processed. Try later.
2022-08-08 09:17:16 bn917 [ENTRY 220808100101248::OPEN] PE NOT complete, sent MARKET order
2022-08-08 09:17:16 modifyOrder_strat fnc error: Order cannot be modified as it is being processed. Try later.
2022-08-08 09:17:22 bn917 [ENTRY 220808100101248::OPEN] PE NOT complete, sent MARKET order
2022-08-08 09:17:22 modifyOrder_strat fnc error: Order cannot be modified as it is being processed. Try later.
I had to manually modify it in kite-web to market order for the order to be placed. As you can see below, no action was received at your end. But I did send the mod order and got a response.



Please advise.

Thanks.
Tagged:
  • sujith
    sujith edited August 2022
    @raja1sttarde,
    If you get 200 for order modify request then it means the modification request is placed at the OMS successfully. It doesn't mean order is modified. Once modify request is placed, there are series of checks that an order goes through and then only gets modified if everything is alright.
    You will have to fetch orderbook and check the status_message field to know the reason if order is not modified.
  • raja1sttarde
    @sujith thank for your reply.

    I capture the order status through the websocket onOrder function. In my above log, the status message 'OPEN' is the latest status message at the time. Looking at the log of the status message;
    220808100101248,	BANKNIFTY2281137800PE,	2022-08-08 09:17:01,	OPEN,	  350.9,	0,	0,LIMIT
    220808100101248, BANKNIFTY2281137800PE, 2022-08-08 09:17:29, UPDATE, 350.9, 0, 0,LIMIT
    220808100101248, BANKNIFTY2281137800PE, 2022-08-08 09:17:29, OPEN, 0, 0, 0,MARKET
    220808100101248, BANKNIFTY2281137800PE, 2022-08-08 09:17:29, COMPLETE, 0, 0, 344.15,MARKET
    It is a mirror of the action on kite-web order history.

    after 10 secs of order placement (09:17:01), i sent auto order mod request (at, 09:17:11, 09:17:16, 09:17:22, 5 seconds apart) and did get valid response, but per your order system there was no modification request.

    This has never happened before, so
    • wanted to bring to your notice, the system did respond in manner documented, but no action was initiated
    • was looking for suggestion how to capture such an off-chance event, should I look for a 'UPDATE' status after placing a mod order?
    Thanks.
  • sujith
    I would suggest don't rely on the postback data, since it is asynchronous in nature. You can just use it as an event to fetch orderbook and check the relevant fields.

    Did you get 200 response for modify request you sent or did you get non-200 response?
  • raja1sttarde
    raja1sttarde edited August 2022
    @sujith i use php to send orders, my function is;

    try
    {
    //send order
    }
    catch(exception $e)
    {
    return $e->getMessage();
    }
    I never had a problem so never really created a detailed log for order related functions. how do I capture the http response code?


    thanks!
  • SRIJAN
    SRIJAN edited August 2022
    @raja1sttarde ,

    Sujith Sir asked if the response for your modify order request was 200 or non-200.

    200 means the request was successfully placed with the OMS. In this the data field in the response is order_id.

    https://kite.trade/docs/connect/v3/orders/#modifying-orders

    Anything other than 200 means an exception.
    In this,the data field in the response is the exception message.

    You got error code 400 ,i.e InputException.
    And the message was , 'Order can't be processed...'


    You can read about KiteConnect exceptions here:

    https://kite.trade/docs/connect/v3/exceptions/
  • SRIJAN
    SRIJAN edited August 2022
    You can enable debug logs here during initialisation of KiteConnect object.

    https://github.com/zerodha/phpkiteconnect/blob/c5eaa092dbc7898c5894d0438d1c7ac24fa1102e/src/KiteConnect.php#L230


    You can also get the error code directly from the exception.
    Although,I know how to do it in python,but not in php.
    I can just tell that there should be a 'code' attribute in the exception thrown by php client.


    Read here about which code indicates which exception:

    https://github.com/zerodha/phpkiteconnect/tree/master/src/Exception

    Still,I can't understand one thing, @rakeshr Sir,
    why is the code for InputException 500 in the php client??

    https://github.com/zerodha/phpkiteconnect/blob/c5eaa092dbc7898c5894d0438d1c7ac24fa1102e/src/Exception/InputException.php#L18

    As far as I understood from the documentation,400 should be the error code for InputException

    https://kite.trade/docs/connect/v3/exceptions/#common-http-error-codes

    and the same is shown in the python client:

    https://github.com/zerodha/pykiteconnect/blob/e6fe14dd403d0af4ee56ce8aa862bbf7352e3795/kiteconnect/exceptions.py#L59
  • raja1sttarde
    @sujit @SRIJAN , thank you very much for such a detailed answer. I will go through all the links again. I didn't have debug initiated before. I will run it in debug mode now. If I run into any problems I will ask.

    Thanks!!
  • rakeshr
    Still,I can't understand one thing, @rakeshr Sir,
    why is the code for InputException 500 in the php client?
    Thanks for highlighting this. I will review and update the same.
  • raja1sttarde
    @SRIJAN I initiated the debug. In php the debug messages are echoed out. I went into the kiteconnect.php file, edited it to pipe the messages to a file.

    In python, kiteconnect is installed via pip. if I wanted to do the same thing in python, ie, pipe the error messages to a file, how would i do it?

    Thanks.
  • SRIJAN
    SRIJAN edited August 2022
  • SRIJAN
    You are sending incorrect order_id.

    Your order_id is ...409 ,as can be seen in your log.

    But,you are sending modify order request for order_id ...255,which must have been already executed .
  • raja1sttarde
    @SRIJAN my comment doesn't even show posted, but you some how you got it. Thanks you so much! U r a super star!!
Sign In or Register to comment.