Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    Execute Hoya hai ya nhi ka logic for niche di coding ke mutabik

    General Discussion
    0
    1
    6
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      as5320029 last edited by

      Respected Sir/ma'am,

      Sir/ma'am muje app ki ik help chahiye thi kafi din parshan hu

      Problem - yeh aa rahi hai ke Jab order place hota hai execute nhi huya hota hai tab LIVE_FEED_JSON['3045']['ltp'] < 760 hone par short sell order lag jata hai

      Main chatahu - Jab order place hota hai fir execute ho tab hi place order ki position exit ke liye sell order request lagaye

      Execute ka logic add kare - jab place huya order execute na ho tab tak place order ki position exit karne ki liye sell order request na Lage

      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
      
          except Exception as e:
              print("Main loop error:", e)
              # Retry placing orders if an error occurs
              continue
      
          time.sleep(10)
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post