Square off Normal and CO orders

tsgoud69
Hi,
I have looked through documentation. Did not see any function to square off intraday position. How to square off positions?
  • sujith
    Hi,
    You will have to place a sell market order for the same instrument with same product to close long position and buy market order for the short position.
  • tsgoud69
    tsgoud69 edited November 2017
    Hi @sujith,
    Thanks for the quick reply, If below is the order I placed for CO BUY INFY.
    What should be my order to square it
    order_id = kite.order_place(tradingsymbol="INFY",exchange="NSE",quantity=10,trigger_price=923,variety="co",transaction_type="BUY",order_type="MARKET",product="MIS",validity="DAY")
  • sujith
    Hi,
    To exit special order like bracket or cover order. Check out this example.
  • tsgoud69
    Hi @sujith,

    I am not a Java guy, is there a python equivalent please.
  • sujith
    Hi @tsgoud69,
    You just need to pass same parameters.
    It just requires order_id, parent_order_id and variety.
  • tsgoud69
    tsgoud69 edited November 2017
    def order_cancel(self, order_id, variety="regular", parent_order_id=None):
    """Cancel an order"""
    return self._delete("orders.cancel", {
    "order_id": order_id,
    "variety": variety,
    "parent_order_id": parent_order_id
    })["order_id"]
    Hi @sujith
    I found this in python code, Is this the one I should be using? If so what is parent order Id?
  • sujith
    Hi,
    Yes, you just need to call that method.
    Let's say your first leg is already executed, for each second leg orders, there will be parent_order_id which points to the first leg order. You just need to pass that value which exiting bracket and cover orders.
  • tsgoud69
    tsgoud69 edited November 2017
    [{'average_price': 920.9,
    'cancelled_quantity': 0,
    'disclosed_quantity': 0,
    'exchange': 'NSE',
    'exchange_order_id': '1100000002147921',
    'exchange_timestamp': '2017-11-02 10:30:19',
    'filled_quantity': 10,
    'instrument_token': 408065,
    'market_protection': 0,
    'order_id': '171102000492879',
    'order_timestamp': '2017-11-02 10:30:19',
    'order_type': 'MARKET',
    'parent_order_id': None,
    'pending_quantity': 0,
    'placed_by': 'XXXX',
    'price': 0,
    'product': 'CO',
    'quantity': 10,
    'status': 'COMPLETE',
    'status_message': None,
    'tag': None,
    'tradingsymbol': 'INFY',
    'transaction_type': 'SELL',
    'trigger_price': 924,
    'validity': 'DAY',
    'variety': 'co'},
    Hi @sujith,
    I just placed above order to SELL(short) 10 INFY shares with variety CO. Please let me know, what is order_id and parent_order_id) that I should use for the below method.


    order_cancel(self, order_id, variety="regular", parent_order_id=None):
  • tsgoud69
    Got it Thanks
This discussion has been closed.