rishiswethan2

Check order placement

Jul 17th, 2019
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.56 KB | None | 0 0
  1. def check_order_placement(order_ids, order_type=None):
  2.     """
  3.    Input:
  4.        A list of order ids[] and optional order_type parameter to check if the order has the particular order parameter
  5.    Output:
  6.        A dict with the order id as index and boll with success status
  7.    """
  8.     order_list = kite.orders()
  9.     orderid_status = {}
  10.     orderid_success = {}
  11.     for order in order_list:
  12.         # print(order)
  13.         orderid_status[str(order['order_id'])] = order
  14.  
  15.     for order_id in order_ids:
  16.         order_id = str(order_id)
  17.         if str(order_id) in orderid_status.keys():
  18.             if orderid_status[str(order_id)]['status'].lower() == 'REJECTED'.lower():
  19.                 util.send_to_admin(subject='Order rejected in ' + orderid_status[order_id]['tradingsymbol'], message=str(orderid_status[order_id]))
  20.                 orderid_success[str(order_id)] = False
  21.             elif (order_type != None):
  22.                 if order_type != orderid_status[str(order_id)]['order_type']:
  23.                     util.send_to_admin(subject='Order type mismatch in ' + orderid_status[order_id]['tradingsymbol'],
  24.                                        message=str(orderid_status[order_id]),
  25.                                        make_call=True)
  26.                     orderid_success[str(order_id)] = False
  27.             else:
  28.                 print(order_id, 'success')
  29.                 orderid_success[str(order_id)] = True
  30.         else:
  31.             orderid_success[str(order_id)] = True
  32.  
  33.     # print(orderid_success)
  34.     # print(orderid_status)
  35.     return orderid_success
Add Comment
Please, Sign In to add comment