Why do I need to specify quantity while modifying order - This is a big problem!!

KamalChhirang
KamalChhirang edited February 26 in Python client
There is a change in Kite API, and it is a big problem. Let me explain.

I tried to modify some orders today


kite.modify_order(variety=order["variety"], order_id=order["order_id"], trigger_price=price)

and I got an error saying, invalid quantity. Now to fix this error, I need to give "quantity" as input parameter like this.

kite.modify_order(variety=order["variety"], order_id=order["order_id"], trigger_price=price,quantity=order["pending_quantity"])

But this is a big problem. I don't know, what is the "pending_quantity". If I have a open order, "pending_quantity" can change any milisecond, and I might end up trading more quantity.

For example:

I placed a buy order of IDEA at 16 INR with 100k quantity.

I want to modify the price to 16.05 now. This is what I need to do

1.) Fetch pending quantity first using kite.orders()
2.) Send modify order request with price 16.05 and quanaity = pending quantity.

But after the 1st step, it is possible more quantity are filled in my IDEA order, and I end up buying more quanaity than required.

Please remove this update or fix this bug as soon as possible. @sujith @MAG @rakeshr
  • santhanakrishnan25
    i also faced the same.
  • sujith
    @KamalChhirang,
    It makes sense. We have asked the concerned team to take a look at this. You can follow up here.
  • sujith
    @KamalChhirang,
    Please note that if you send original quantity while modifying the order, it won't increase the total order quantity.
  • KamalChhirang
    KamalChhirang edited February 26
    Edit: Testing
  • KamalChhirang
    KamalChhirang edited February 26
    @sujith Tested it on a illiquid script. Seems to work.

    But I tried this earlier today, and as far as I remember, it increased the quantity by
    "original quantity + filled_quantity"
    Is this a new update you guys made just now? Or it was like this before also?
  • sujith
    sujith edited February 26
    It was always like this. The quantity value will not add to order's original quantity but modify the order's original quantity. It doesn't matter if order is in pending or partially filled state.
  • santhanakrishnan25
    Sent quantity and things were fine. But if i send the same orderType it throws the error. Sending the order type as none now. Hope SL LIMIT to MARKET order conversion works fine @sujith
    2024-02-26 13:27:36,890 - INFO - zerodha Order modify failed: Invalid order_type. - 81
    2024-02-26 13:27:36,890 - ERROR - TradeManager: Failed to update SL for tradeID cf09091a-8513-4559-a95e-8cd9a202cbe9 orderId 240226502256281: Error => Invalid order_type. - 702
    2024-02-26 13:27:38,077 - INFO - zerodha: Going to modify order with params newPrice=50.9, newTriggerPrice=50.8, newQty=75, newOrderType=SL_LIMIT - 63
    2024-02-26 13:27:38,090 - INFO - rb1 Min PNL -71 - 526
Sign In or Register to comment.