Navigation

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

    'TypeError' object has no attribute 'message' Error while placing order

    Python SDK
    0
    5
    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.
    • P
      pankaj8932 last edited by

      Hello sir, I am unable to place order using your sample code. I am able to generate tokens but while placing order it gives error "'TypeError' object has no attribute 'message'" . I am using below code</br>
      </br>

      obj=SmartConnect(api_key="XXXX") #"XXXX replaced with api key"</br>
      data = obj.generateSession("P51757","XXXX") #"XXXX replaced with pass"</br>
      refreshToken= data['data']['refreshToken']</br>
      feedToken=obj.getfeedToken()</br>
      userProfile= obj.Profile(refreshToken)</br>

      try:</br>
      orderparams = {</br>
      "variety": "NORMAL",</br>
      "tradingsymbol": "SBIN-EQ",</br>
      "symboltoken": "3045",</br>
      "transactiontype": "BUY",</br>
      "exchange": "NSE",</br>
      "ordertype": "LIMIT",</br>
      "producttype": "MARGIN",</br>
      "duration": "DAY",</br>
      "price": "477",</br>
      "squareoff": "0",</br>
      "stoploss": "0",</br>
      "quantity": "1"</br>
      }</br>
      orderId=object.placeOrder(orderparams)</br>
      print("The order id is: {}".format(orderId))</br>
      return orderId</br>
      except Exception as e:</br>
      print("Order placement failed: {}".format(e.message))</br>
      return "Not Placed"</br>
      </br>
      Can you please let me know what causing the issue.
      Thanks

      N 1 Reply Last reply Reply Quote 0
      • P
        pankaj8932 last edited by

        @admin Can you please check what is the issue with my user. Is there any settings need to enable for my user?

        1 Reply Last reply Reply Quote 0
        • N
          neeluru @pankaj8932 last edited by

          @pankaj8932
          I am also facing same issue. Is it resolved ?

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

            Hi @neeluru

            We have replied to your query here - https://smartapi.angelbroking.com/topic/1538/order-placement-failed-nonetype-object-is-not-subscriptable

            1 Reply Last reply Reply Quote 0
            • L
              laxm last edited by

              Hi @pankaj8932 @neeluru

              By any chance is this resolved for you?

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