How to place order along with exit order at once?

amandeep179018
amandeep179018 edited December 2019 in Python client
# BUY
if (b+14)==a:
print(b)
kite.place_order(tradingsymbol='SILVERMIC20FEBFUT',
price=company_data['last_price'],
variety=kite.VARIETY_CO,
exchange=kite.EXCHANGE_MCX,
transaction_type=kite.TRANSACTION_TYPE_BUY,
quantity=3,
squareoff=1000,
stoploss=1000,
order_type=kite.ORDER_TYPE_MARKET,
product=kite.PRODUCT_CO)

# here I want to place an exit order

I'm placing my order after an if statement as shown above. I want to place an exit order along with it so that when the order gets triggered then a stop loss is automatically get placed.

syntax of exit order:

def exit_order(self, variety, order_id, parent_order_id=None):
"""Exit a BO/CO order."""
self.cancel_order(variety, order_id, parent_order_id=parent_order_id)

how can I get the parent order id in the loop?
Tagged:
  • sujith
    If you place a cover order, the system will take care of placing the second leg order. You don't have to explicitly place another order.

    The order place response will give you an order id which is the parent order id of the second leg order. You need to fetch orderbook and find the order which has parent order id same as the one received.
Sign In or Register to comment.