what happens after stop loss market order is complete? how to cancel it,what is order_id of position

manoj2161
I have setup regular SL-M order, both buy and sell side, kind of range break out in any direction. let's say buy side is hit.
SL-M order gets completed. Now there is a intraday position. but kite.orders() is not giving the orderid of this position.

[{'parent_order_id': None, 'market_protection': 0, 'product': 'MIS', 'exchange_order_id': '1100000004831115', 'exchange_timestamp': datetime.datetime(2020, 5, 29, 10, 46), 'status': 'TRIGGER PENDING', 'validity': 'DAY', 'variety': 'regular', 'order_id': '200529001791902', 'price': 0, 'average_price': 0, 'trigger_price': 9381.25, 'order_type': 'SL-M', 'guid': '14947XRrSkmlSh5MXY', 'meta': {}, 'exchange': 'NFO', 'tradingsymbol': 'NIFTY20JUNFUT', 'status_message': None, 'tag': 'twhbc', 'placed_by': 'ZM5768', 'status_message_raw': None, 'disclosed_quantity': 0, 'order_timestamp': datetime.datetime(2020, 5, 29, 10, 46), 'cancelled_quantity': 0, 'instrument_token': 24507906, 'pending_quantity': 150, 'exchange_update_timestamp': '2020-05-29 10:46:00', 'filled_quantity': 0, 'transaction_type': 'SELL', 'tags': ['twhbc'], 'quantity': 150},
{'parent_order_id': None, 'market_protection': 0, 'product': 'MIS', 'exchange_order_id': '1100000004831321', 'exchange_timestamp': datetime.datetime(2020, 5, 29, 10, 46, 1), 'status': 'OPEN', 'validity': 'DAY', 'variety': 'regular', 'order_id': '200529001791964', 'price': 9535.45, 'average_price': 0, 'trigger_price': 0, 'order_type': 'LIMIT', 'guid': '14947X9SNL4aR5o53U', 'meta': {}, 'exchange': 'NFO', 'tradingsymbol': 'NIFTY20JUNFUT', 'status_message': None, 'tag': 'twhbc', 'placed_by': 'ZM5768', 'status_message_raw': None, 'disclosed_quantity': 0, 'order_timestamp': datetime.datetime(2020, 5, 29, 10, 46, 1), 'cancelled_quantity': 0, 'instrument_token': 24507906, 'pending_quantity': 150, 'exchange_update_timestamp': '2020-05-29 10:46:01', 'filled_quantity': 0, 'transaction_type': 'SELL', 'tags': ['twhbc'], 'quantity': 150},
{'parent_order_id': None, 'market_protection': 0, 'product': 'MIS', 'exchange_order_id': '1100000004831507', 'exchange_timestamp': datetime.datetime(2020, 5, 29, 10, 46, 1), 'status': 'OPEN', 'validity': 'DAY', 'variety': 'regular', 'order_id': '200529001792049', 'price': 9297.5, 'average_price': 0, 'trigger_price': 0, 'order_type': 'LIMIT', 'guid': '14947X9r51MPreQ5QS', 'meta': {}, 'exchange': 'NFO', 'tradingsymbol': 'NIFTY20JUNFUT', 'status_message': None, 'tag': 'twhbc', 'placed_by': 'ZM5768', 'status_message_raw': None, 'disclosed_quantity': 0, 'order_timestamp': datetime.datetime(2020, 5, 29, 10, 46, 1), 'cancelled_quantity': 0, 'instrument_token': 24507906, 'pending_quantity': 150, 'exchange_update_timestamp': '2020-05-29 10:46:01', 'filled_quantity': 0, 'transaction_type': 'BUY', 'tags': ['twhbc'], 'quantity': 150},
{'parent_order_id': None, 'market_protection': 0, 'product': 'MIS', 'exchange_order_id': '1100000004830921', 'exchange_timestamp': datetime.datetime(2020, 5, 29, 11, 35, 34), 'status': 'COMPLETE', 'validity': 'DAY', 'variety': 'regular', 'order_id': '200529001791831', 'price': 0, 'average_price': 9467.525, 'trigger_price': 9466, 'order_type': 'LIMIT', 'guid': '14947XOkH8EYGSAfGk', 'meta': {}, 'exchange': 'NFO', 'tradingsymbol': 'NIFTY20JUNFUT', 'status_message': None, 'tag': 'twhbc', 'placed_by': 'ZM5768', 'status_message_raw': None, 'disclosed_quantity': 0, 'order_timestamp': datetime.datetime(2020, 5, 29, 11, 35, 34), 'cancelled_quantity': 0, 'instrument_token': 24507906, 'pending_quantity': 0, 'exchange_update_timestamp': '2020-05-29 11:35:34', 'filled_quantity': 150, 'transaction_type': 'BUY', 'tags': ['twhbc'], 'quantity': 150}]
  • sujith
    Unfortunately, OMS doesn't have a mechanism to map a position to orders. It just shows your mark to market.
    For an SL-M order, once the trigger is hit, a market order is placed. Hence orderbook will show order type as MARKET for this entry.
    Maybe you can use the tag feature to tag your orders and cancel the opposite side orders from orderbook.

    There will be one position entry for an instrument in the same product type on positions even though there are multiple orders executed on that instrument.
  • sujith
    Multiple orders consolidate to one position is what I meant.
  • manoj2161
    is there a way to cancel this position programatically? that is what i am looking for.

    "Maybe you can use the tag feature to tag your orders and cancel the opposite side orders from orderbook." this statement i am not able to understand. the log, which i pasted has the output of kite.orders, it does not show any new entry, when i tried cancelling other three it worked. but position was still alive. i want a way to exit this position
  • sujith
    In order to close a position, you need to place a market order with the same product type (MIS/NRML) and the opposite transaction type. If it is bracket or cover order then you need to send an exit request as mentioned here.

    What I meant was, if you are running multiple strategies on the same instrument then you can use the tag feature to keep track of quantities of different strategies, which you already seem to be using. You have set the value as 'twhbc'
Sign In or Register to comment.