Request Help: Code for Finding the Present Status of a Placed Order

aabhalerao
Hi,
I use following -
>>> order_details=kite.order_history(order_id=order_id)
to get the Details of a specific Order.

I want to extract the Last status like "Trigger Pending" or "Cancelled" in order to take further action.

Pls help with a code example to extract the last status from the big response received for the order history
Getting over this will help me complete my Auto Trading Strategy Code.

Thanks in advance...
  • sujith
    sujith edited June 2018
    You can fetch order history and check for the latest status. You can check out documentation and pykiteconnect documentation.
  • sujith
    You can also fetch orderbook and check for the status field.
  • aabhalerao
    Hi Sujith
    Thanks for the prompt reply.

    But it does not help me get over my issue. I know this method will address the issue but
    I am actually UNABLE TO WRITE CODE to EXTRACT THE LAST STATUS from the Big response received.
    Being little new to python unable to use get etc. on the response.

    I do not want to bother you personally, Maybe somebody else on the forum can help by a code example.....

    I am pasting a typical response here ....

    >>> order_details=kite.order_history(order_id=order_id)
    >>> order_details
    [{'placed_by': 'xxxxxx', 'order_id': '180614000756121', 'exchange_order_id': None, 'parent_order_id': None, 'status': 'PUT ORDER REQ RECEIVED', 'status_message': None, 'order_timestamp': datetime.datetime(2018, 6, 14, 10, 43, 44), 'exchange_update_timestamp': None, 'exchange_timestamp': None, 'variety': 'regular', 'exchange': 'NFO', 'tradingsymbol': 'NIFTY18JUNFUT', 'instrument_token': 2, 'order_type': 'SL', 'transaction_type': 'BUY', 'validity': 'DAY', 'product': 'NRML', 'quantity': 75, 'disclosed_quantity': 0, 'price': 10855, 'trigger_price': 10850, 'average_price': 0, 'filled_quantity': 0, 'pending_quantity': 75, 'cancelled_quantity': 0, 'market_protection': 0, 'tag': None, 'guid': 'TmMp5g3dzDlKeEX3'},

    {'placed_by': 'xxxxxx', 'order_id': '180614000756121', 'exchange_order_id': None, 'parent_order_id': None, 'status': 'VALIDATION PENDING', 'status_message': None, 'order_timestamp': datetime.datetime(2018, 6, 14, 10, 43, 44), 'exchange_update_timestamp': None, 'exchange_timestamp': None, 'variety': 'regular', 'exchange': 'NFO', 'tradingsymbol': 'NIFTY18JUNFUT', 'instrument_token': 12374274, 'order_type': 'SL', 'transaction_type': 'BUY', 'validity': 'DAY', 'product': 'NRML', 'quantity': 75, 'disclosed_quantity': 0, 'price': 10855, 'trigger_price': 10850, 'average_price': 0, 'filled_quantity': 0, 'pending_quantity': 75, 'cancelled_quantity': 0, 'market_protection': 0, 'tag': None, 'guid': 'TmMp5g3dzDlKeEX3'},

    {'placed_by': 'xxxxxx', 'order_id': '180614000756121', 'exchange_order_id': None, 'parent_order_id': None, 'status': 'OPEN PENDING', 'status_message': None, 'order_timestamp': datetime.datetime(2018, 6, 14, 10, 43, 44), 'exchange_update_timestamp': None, 'exchange_timestamp': None, 'variety': 'regular', 'exchange': 'NFO', 'tradingsymbol': 'NIFTY18JUNFUT', 'instrument_token': 12374274, 'order_type': 'SL', 'transaction_type': 'BUY', 'validity': 'DAY', 'product': 'NRML', 'quantity': 75, 'disclosed_quantity': 0, 'price': 10855, 'trigger_price': 10850, 'average_price': 0, 'filled_quantity': 0, 'pending_quantity': 75, 'cancelled_quantity': 0, 'market_protection': 0, 'tag': None, 'guid': 'TmMp5g3dzDlKeEX3'},

    {'placed_by': 'xxxxxx', 'order_id': '180614000756121', 'exchange_order_id': '1100000000202510', 'parent_order_id': None, 'status': 'TRIGGER PENDING', 'status_message': None, 'order_timestamp': datetime.datetime(2018, 6, 14, 10, 43, 44), 'exchange_update_timestamp': None, 'exchange_timestamp': datetime.datetime(2018, 6, 14, 10, 43, 44), 'variety': 'regular', 'exchange': 'NFO', 'tradingsymbol': 'NIFTY18JUNFUT', 'instrument_token': 12374274, 'order_type': 'SL', 'transaction_type': 'BUY', 'validity': 'DAY', 'product': 'NRML', 'quantity': 75, 'disclosed_quantity': 0, 'price': 10855, 'trigger_price': 10850, 'average_price': 0, 'filled_quantity': 0, 'pending_quantity': 75, 'cancelled_quantity': 0, 'market_protection': 0, 'tag': None, 'guid': 'TmMp5g3dzDlKeEX3'},

    {'placed_by': 'xxxxxx', 'order_id': '180614000756121', 'exchange_order_id': '1100000000202510', 'parent_order_id': None, 'status': 'CANCEL PENDING', 'status_message': None, 'order_timestamp': datetime.datetime(2018, 6, 14, 13, 25, 34), 'exchange_update_timestamp': None, 'exchange_timestamp': datetime.datetime(2018, 6, 14, 10, 43, 44), 'variety': 'regular', 'exchange': 'NFO', 'tradingsymbol': 'NIFTY18JUNFUT', 'instrument_token': 12374274, 'order_type': 'SL', 'transaction_type': 'BUY', 'validity': 'DAY', 'product': 'NRML', 'quantity': 75, 'disclosed_quantity': 0, 'price': 10855, 'trigger_price': 10850, 'average_price': 0, 'filled_quantity': 0, 'pending_quantity': 75, 'cancelled_quantity': 0, 'market_protection': 0, 'tag': None, 'guid': 'TmMp5g3dzDlKeEX3'},

    {'placed_by': 'xxxxxx', 'order_id': '180614000756121', 'exchange_order_id': '1100000000202510', 'parent_order_id': None, 'status': 'CANCELLED', 'status_message': None, 'order_timestamp': datetime.datetime(2018, 6, 14, 13, 25, 34), 'exchange_update_timestamp': None, 'exchange_timestamp': datetime.datetime(2018, 6, 14, 10, 43, 44), 'variety': 'regular', 'exchange': 'NFO', 'tradingsymbol': 'NIFTY18JUNFUT', 'instrument_token': 12374274, 'order_type': 'SL', 'transaction_type': 'BUY', 'validity': 'DAY', 'product': 'NRML', 'quantity': 75, 'disclosed_quantity': 0, 'price': 10855, 'trigger_price': 10850, 'average_price': 0, 'filled_quantity': 0, 'pending_quantity': 0, 'cancelled_quantity': 75, 'market_protection': 0, 'tag': None, 'guid': 'TmMp5g3dzDlKeEX3'},

    {'placed_by': 'xxxxxx', 'order_id': '180614000756121', 'exchange_order_id': '1100000000202510', 'parent_order_id': None, 'status': 'CANCELLED', 'status_message': None, 'order_timestamp': datetime.datetime(2018, 6, 14, 13, 25, 34), 'exchange_update_timestamp': None, 'exchange_timestamp': datetime.datetime(2018, 6, 14, 10, 43, 44), 'variety': 'regular', 'exchange': 'NFO', 'tradingsymbol': 'NIFTY18JUNFUT', 'instrument_token': 12374274, 'order_type': 'SL', 'transaction_type': 'BUY', 'validity': 'DAY', 'product': 'NRML', 'quantity': 75, 'disclosed_quantity': 0, 'price': 10855, 'trigger_price': 10850, 'average_price': 0, 'filled_quantity': 0, 'pending_quantity': 75, 'cancelled_quantity': 75, 'market_protection': 0, 'tag': None, 'guid': 'TmMp5g3dzDlKeEX3'}]
  • aabhalerao
    HI,
    I managed to extract the last status of a placed order.
    Thanks....
This discussion has been closed.