how to square off BO orders for multiple lots

RH1558
RH1558 edited September 2016 in API clients
how to square off BO orders for multiple lots
place order for 5 lot on ACC
1)trigger hit for 5 lots and target/stoploss rich by 3 lots, then how to square off 2 lots.
2)trigger hit for 3 lots and target/stoploss rich by 3 lots, then how to square off 2 lots.
Tagged:
  • Vivek
    You can exit the current order as usual and the remaining lots will be squared off - https://kite.trade/docs/connect/v1/#cancelling-orders

    In both the cases when you exit the BO order the remaining 2 lots will be squared off.
  • Pushwinder
    kite.order_cancel(parent_order_id="") is not working for naturalgas16novfut,
    I had placed an CO on naturalgas, was not able to exit the order using the above statement, the error received was

    TypeError: order_cancel() missing 1 required positional argument: 'order_id'

    when I used the order_id, which is normally +1 the parent_order_id it showed,

    kiteconnect.exceptions.OrderException: The order couldn't be cancelled
  • sujith
    Hi @Pushwinder,
    Try sending order_id and parent_id.

    Note: partial exit of special orders(BO and CO) is not available.
  • Pushwinder
    Have tried that too, not working, same error
    kiteconnect.exceptions.OrderException: The order couldn't be cancelled
  • Vivek
    @Pushwinder This is happens when order is already cancelled/exited and you are trying to cancel/exit it again. Can you please check in orderbook if the order is still pending before you try to cancel/exit? also for CO it s optional to send parent_order_id while exiting.
  • Pushwinder
    No sir, I have tried it a lot of times, The order which I am trying to cancel are present on the OPEN ORDERS list, I am able to place orders easily, but Exit using kite.order_cancel(order_id) is not working for me.
  • sujith
    Hi @Pushwinder,

    Are you trying to do partial exit?
  • Pushwinder
    No sir, full exit, I am just a novice trader, started with kite APIs recently, and just trying out with single quantity in Naturalgas16novfut. I am able to place order but not able to exit it.
    I am using these formats, tell me if I am wrong
    kite.order_cancel(order_id="161115000491500") and
    kite.order_cancel(order_id="161115000491500",parent_order_id="161115000491499")
  • sujith
    @Pushwinder,
    what client are you using java or python?
  • sujith
    Hi @Pushwinder,

    Can you paste your code for cancelling BO?
  • Pushwinder
    I have tried both these codes:
    kite.order_cancel(order_id="161115000491500")
    kite.order_cancel(order_id="161115000491500",parent_order_id="161115000491499")

    but the error message i got is this:
    kiteconnect.exceptions.OrderException: The order couldn't be cancelled

    whereas, this order was present in Open Orders List
  • Vivek
    @Pushwinder You have to pass variety while cancelling orders. By default its taken as "regular" if it wasn't mentioned. For example

    kite.order_cancel("161115000491500", variety="bo", parent_order_id="161115000491499")
  • Pushwinder
    Now the error I am getting is
    kiteconnect.exceptions.GeneralException: Route not found
    This is syntax i used:
    kite.order_cancel(order_id="161122000412518",variety="CO",parent_order_id="161122000412517")
  • Vivek
    @Pushwinder Variety should be one of "regular", "bo", "co", "amo" all in lowercase.
  • Pushwinder
    Thank You Sir, Its working
This discussion has been closed.