Navigation

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

    option order is not placing

    General Discussion
    3
    6
    61
    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.
    • R
      rishi6310 last edited by

      i have try to place order in nifty option but not able to place

      from smartapi import SmartConnect
      from smartapi import SmartWebSocket
      import login as l

      obj=SmartConnect(api_key=l.api_key)
      data = obj.generateSession(l.user_name,l.password)
      refreshToken= data['data']['refreshToken']
      #fetch the feedtoken
      feedToken=obj.getfeedToken()
      l.feed_token = feedToken
      #fetch User Profile
      userProfile= obj.getProfile(refreshToken)

      try:
      orderparams = {
      "variety": "NORMAL",
      "tradingsymbol": "NIFTY25NOV2117600CE",
      "symboltoken": "54385",
      "transactiontype": "buy",
      "exchange": "NFO",
      "ordertype": "LIMIT",
      "producttype": "CARRYFORWARD",
      "duration": "DAY",
      "price": "0",
      "squareoff": "0",
      "stoploss": "0",
      "quantity": "1"
      }
      orderId=obj.placeOrder(orderparams)
      print("The order id is: {}".format(orderId))
      except Exception as e:
      print("Order placement failed: {}".format(e.message))

      error showing :
      Traceback (most recent call last):
      File "C:\Users\rishi\PycharmProjects\pythonProjectnew\venv\lib\site-packages\smartapi\smartConnect.py", line 188, in request
      data = json.loads(r.content.decode("utf8"))
      File "C:\Program Files\Python310\lib\json_init
      .py", line 346, in loads
      return _default_decoder.decode(s)
      File "C:\Program Files\Python310\lib\json\decoder.py", line 337, in decode
      obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "C:\Program Files\Python310\lib\json\decoder.py", line 355, in raw_decode
      raise JSONDecodeError("Expecting value", s, err.value) from None
      json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File "C:\Users\rishi\PycharmProjects\pythonProjectnew\error.py", line 36, in <module>
      orderId=obj.placeOrder(orderparams)
      File "C:\Users\rishi\PycharmProjects\pythonProjectnew\venv\lib\site-packages\smartapi\smartConnect.py", line 290, in placeOrder
      orderResponse= self._postRequest("api.order.place", params)['data']['orderid']
      File "C:\Users\rishi\PycharmProjects\pythonProjectnew\venv\lib\site-packages\smartapi\smartConnect.py", line 220, in _postRequest
      return self._request(route, "POST", params)
      File "C:\Users\rishi\PycharmProjects\pythonProjectnew\venv\lib\site-packages\smartapi\smartConnect.py", line 191, in _request
      raise ex.DataException("Couldn't parse the JSON response received from the server: {content}".format(
      smartapi.smartExceptions.DataException: Couldn't parse the JSON response received from the server: b''

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File "C:\Users\rishi\PycharmProjects\pythonProjectnew\error.py", line 39, in <module>
      print("Order placement failed: {}".format(e.message))
      AttributeError: 'DataException' object has no attribute 'message'

      please tell how to squareoff order in option

      S A 2 Replies Last reply Reply Quote 0
      • S
        Surya 1 @rishi6310 last edited by

        @rishi6310 said in option order is not placing:

        NIFTY25NOV2117600CE

        Limit order with price zero ?

        R 1 Reply Last reply Reply Quote 0
        • R
          rishi6310 @Surya 1 last edited by

          @rajanprabu i have try with market order but result is same

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

            Hi @rishi6310 said in option order is not placing:

            please tell how to squareoff order in option

            it is similar how you do it in equity and other segment initiate reverse order to the one which you entered while executing keeping the transaction type as sell and other parameters same.

            R 1 Reply Last reply Reply Quote 0
            • R
              rishi6310 @admin last edited by

              @admin i have try this but it executed order on sell side and my position doesn't square in option

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

                @rishi6310 send us the request which you executed to take the position and the req which you executed for selling.

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