Order status related


  • Sir, I wanted your help for a long time

    Below is the coding related - sell part

    Problem - I have that when the order place is pending but not executed then LIVE_FEED_JSON['3045']['ltp'] < 760 (less than 760) then a short sell order appears.

    I want - when the order is placed and then executed, then only sell order request is made to exit the position of the place order. (If the order is only pending but not executed, then the sell order request should not appear)

    Which function will be required to find out the status of an order through order status so that we can take an action after that.

    def monitor_and_place_orders():
    order_1_placed = False
    order_1_id = None

     while True:
         try:
             if not order_1_placed and '3045' in LIVE_FEED_JSON and LIVE_FEED_JSON['3045']['ltp'] > 764:
                 trigger_price_1 = LIVE_FEED_JSON['3045']['ltp']
                 order_price_1 = LIVE_FEED_JSON['3045']['ltp']
                 order_1_id = place_order_1('3045', '1', trigger_price_1, order_price_1)
                 if order_1_id:
                     print('place_order_1', LIVE_FEED_JSON['3045']['ltp'])
                     order_1_placed = True
                    
    
             # Check for condition to place sell order
             if order_1_placed and '3045' in LIVE_FEED_JSON and LIVE_FEED_JSON['3045']['ltp'] < 760:
                 sell_order_id = place_sell_order('3045', '1', order_1_id)
                 if sell_order_id:
                     print('Sell order placed for order ID:', order_1_id)
                     break # Exit loop after placing sell order