Navigation

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

    Exiting an order with order_id. (Reverse Order with order_id)

    Python SDK
    0
    3
    91
    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.
    • M
      Meghavarsha last edited by

      Hi,

      I place an order using the below code. It creates a new order, say order_id: 1. Now I want to exit this order_id(1). How do I do this? I can get the executed order_ids from Order Book or Trade Book. But how do I place a reverse order for a particular order_id. Every time I use the below code it creates a new order.
      I want to know how to close an exiting order using order_id or any other way to close and existing order.

      Please help. Thank you.

      orderparams = {
      "variety": "NORMAL",
      "tradingsymbol": script,
      "symboltoken": token,
      "transactiontype": BUY/SELL,
      "exchange": exchange,
      "ordertype": "LIMIT",
      "producttype": "INTRADAY",
      "duration": "DAY",
      "price": ltp,
      "squareoff": "0",
      "stoploss": "0",
      "quantity": quantity
      }
      orderId = obj.placeOrder(orderparams)

      A 1 Reply Last reply Reply Quote 0
      • A
        admin @Meghavarsha last edited by

        @Meghavarsha said in Exiting an order with order_id. (Reverse Order with order_id):

        I want to know how to close an exiting order using order_id or any other way to close and existing order.

        There is no mechanism to close a position using order id. The way to do it is to place an opposite BUY or SELL order depending on whether the position is a long or a short. You can fetch open positions from here - https://smartapi.angelbroking.com/docs/Portfolio#position

        L 1 Reply Last reply Reply Quote 0
        • L
          Linux Smiths @admin last edited by

          @admin Related question, how do we do this for a ROBO order where the main order is completed and the two sub-orders are not. Basically this is like squaringoff the order. Unlike the given example, though we can place a new order but we have to cancel the two sub orders, cancelOrder fails.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post