Not able to modify open order using modify_order function

AvinashKrishnappa
Hi,

I have 10 stocks in my holding and now I am placing a limit order to sell 1 stock. after this I am continuously monitoring this order with his order id. Now some condition happens and I want to modify the existing sell order.
below is the code I am calling when ever I want to modify my order. For this function I am passing price, quantity and order id.

def modify_ordr(price, ordr_id, quantity):
ordr_id_r = kite.modify_order(variety='VARIETY_REGULAR',
order_id=ordr_id,
quantity=quantity,
price=price)
return ordr_id

When ever I invoke this function I am getting below error. Please let me know if any one come across this kind of issue.

DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "PUT /orders/VARIETY_REGULAR/201111202205904 HTTP/1.1" 404 None
Traceback (most recent call last):
File "C:/Algo_project/MultiThread.py", line 319, in
Sell_OrderRecords[1] = modify_ordr(price, Sell_OrderRecords[0], 1)
File "C:/Algo_project/MultiThread.py", line 202, in modify_ordr
price=price)
File "C:\Users\Avinash\AppData\Local\Programs\Python\Python36\lib\site-packages\kiteconnect\connect.py", line 366, in modify_order
return self._put("order.modify", params)["order_id"]
File "C:\Users\Avinash\AppData\Local\Programs\Python\Python36\lib\site-packages\kiteconnect\connect.py", line 825, in _put
return self._request(route, "PUT", params)
File "C:\Users\Avinash\AppData\Local\Programs\Python\Python36\lib\site-packages\kiteconnect\connect.py", line 886, in _request
raise exp(data["message"], code=r.status_code)
kiteconnect.exceptions.GeneralException: Route not found
  • dinezh
    dinezh edited November 2020
    @AvinashKrishnappa

    I don't know why it cause this error for sure, it can't find the right route maybe because you're not providing all the information of your order, Incase if you have a trigger price you must include the trigger price also.

    def modify_ordr(price, ordr_id, quantity):
    ordr_id_r = kite.modify_order(variety='VARIETY_REGULAR',
    order_id=ordr_id,
    quantity=quantity,
    price=price)
    return ordr_id
    Are you sure you use this function in your script?
    because the above function is returning ordr_id parameter of your function
    instead of returning the order_id_r which returns the modified order's id

    #######################

    take a look at this you might get an idea
    This is my methods used for Limit buying and modifying my limit buying orders
    works fine for me

    def placeOrder(symbol, price, quantity):
    orderid = kite.place_order(
    variety=kite.VARIETY_REGULAR,
    product= kite.PRODUCT_CNC,
    validity=kite.VALIDITY_DAY,
    exchange=kite.EXCHANGE_NSE,
    tradingsymbol=symbol,
    quantity=quantity,
    price= price,
    trigger_price=price,
    transaction_type=kite.TRANSACTION_TYPE_BUY,
    order_type=kite.ORDER_TYPE_SL
    )
    return orderid

    def modifyOrder(order_id, price):
    orderid = kite.modify_order(
    order_id=order_id,
    variety=kite.VARIETY_REGULAR,
    price=price,
    trigger_price=price,
    )
    return orderid


    Modifying an order via a python script is just like you're modifying your order manually on KITE web app

    So take a close look at how you modify your order on KITE web app and do make it a function on your script that's it.

    I hope this helps.

    :smile:
  • sujith
    @AvinashKrishnappa,
    You seem to be sending a wrong variety value. You are sending a constant name as mentioned in the example, the value is lower case regular
  • AvinashKrishnappa
    Thanks it worked.
This discussion has been closed.