Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def check_order_placement(order_ids, order_type=None):
- """
- Input:
- A list of order ids[] and optional order_type parameter to check if the order has the particular order parameter
- Output:
- A dict with the order id as index and boll with success status
- """
- order_list = kite.orders()
- orderid_status = {}
- orderid_success = {}
- for order in order_list:
- # print(order)
- orderid_status[str(order['order_id'])] = order
- for order_id in order_ids:
- order_id = str(order_id)
- if str(order_id) in orderid_status.keys():
- if orderid_status[str(order_id)]['status'].lower() == 'REJECTED'.lower():
- util.send_to_admin(subject='Order rejected in ' + orderid_status[order_id]['tradingsymbol'], message=str(orderid_status[order_id]))
- orderid_success[str(order_id)] = False
- elif (order_type != None):
- if order_type != orderid_status[str(order_id)]['order_type']:
- util.send_to_admin(subject='Order type mismatch in ' + orderid_status[order_id]['tradingsymbol'],
- message=str(orderid_status[order_id]),
- make_call=True)
- orderid_success[str(order_id)] = False
- else:
- print(order_id, 'success')
- orderid_success[str(order_id)] = True
- else:
- orderid_success[str(order_id)] = True
- # print(orderid_success)
- # print(orderid_status)
- return orderid_success
Add Comment
Please, Sign In to add comment