Navigation

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

    "Order placement failed: 'NoneType' object is not subscriptable"

    Python SDK
    2
    26
    314
    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.
    • C
      charlotteemma @prasan last edited by

      @prasan said in "Order placement failed: 'NoneType' object is not subscriptable":

      "tradingsymbol": "CRUDEOIL21NOV630000PE",
      "symboltoken": "233501",
      "transactiontype": "BUY",
      *** "exchange": "NFO",**

      wrong exchange

      P 1 Reply Last reply Reply Quote 0
      • P
        prasan @charlotteemma last edited by

        @HP Thanks.

        I tried this one as well, both AMO/NORMAL, same result..
        orderparams = {
        "variety": "AMO", # "NORMAL" "AMO", # , #
        "tradingsymbol": "CRUDEOIL21NOV630000PE",
        "symboltoken": "233501",
        "transactiontype": "BUY",
        "exchange": "MCX",
        "ordertype": "MARKET",
        "producttype": "CARRYFORWARD",
        "duration": "IOC", #"DAY"
        "price": "0",
        "squareoff": "0",
        "stoploss": "0",
        "quantity": 100 #quantity #lot size CRUDE 100, NIFTY 50
        }

        C 1 Reply Last reply Reply Quote 0
        • C
          charlotteemma @prasan last edited by

          @prasan
          orderparams={"variety": 'NORMAL',
          "tradingsymbol": 'BANKNIFTY07OCT2136100CE',
          "symboltoken": '40671',
          "transactiontype": 'BUY',
          "exchange": 'NFO',
          "ordertype": 'MARKET',
          "producttype": 'INTRADAY',
          "duration": 'DAY',
          "price": 0.0,
          "squareoff": 0.0,
          "stoploss": 0.0,
          "triggerprice": 0.0,
          "trailingstoploss": 0.0,
          "quantity": 1
          }

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

            @prasan , @admin

            {
            'variety': 'NORMAL',
            'tradingsymbol': 'NIFTY29DEC2218400CE',
            'symboltoken': '86414',
            'transactiontype': 'BUY',
            'exchange': 'NFO',
            'ordertype': 'STOPLOSS_LIMIT',
            'producttype': 'CARRYFORWARD',
            'duration': 'DAY',
            'price': '199.0',
            'triggerprice': '198.95',
            'squareoff': '0',
            'stoploss': '0',
            'quantity': '50'
            }

            am getting an error

            orderResponse= self._postRequest("api.order.place", params)['data']['orderid']
            TypeError: 'NoneType' object is not subscriptable

            Please help

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

              Hi @neeluru

              We have noticed that you are experiencing issues with our SDK due to poor error handling. The error message you are seeing, "TypeError: 'NoneType' object is not subscriptable", is a result of the SDK not handling exceptions properly. This is causing the orderResponse variable to be None, which is leading to the error you are seeing.

              The correct error message from the RestAPI is "Invalid Order Type" with error code "AB1020". This error is likely being caused because you are using the wrong value for the "variety" parameter. For STOPLOSS_MARKET orders, the acceptable input for the "variety" parameter is "STOPLOSS" and not "NORMAL".

              Please note that our SDKs are open source, so you are welcome to make contributions to improve the error handling and other aspects of the code. Additionally, if you encounter any errors in the future, you can make a call to the RestAPI directly to get the correct error message and information on how to resolve the issue.

              We apologize for any inconvenience this may have caused and thank you for your understanding.

              N L 2 Replies Last reply Reply Quote 0
              • N
                neeluru @admin last edited by

                @admin

                Thanks admin.. It's working well now.

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

                  @neeluru

                  Hi, can you please share how it got resolved? I'm facing this issue from many days.

                  N A 2 Replies Last reply Reply Quote 0
                  • L
                    laxm @admin last edited by

                    @admin said in "Order placement failed: 'NoneType' object is not subscriptable":

                    error message from the RestAPI

                    Hi @admin
                    if my understanding is correct you mean to say that this error "'NoneType' object is not subscriptable" is due to wrong "variety" parameter. Please correct if I misunderstood it.

                    I am also facing the same issue regularly. I had already raised this, please see https://smartapi.angelbroking.com/topic/3398/error-while-placing-orders

                    And I checked the "variety" in order parameters, it is "NORMAL" for regular orders and "ROBO" for Bracket orders.

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

                      @laxm
                      below is piece of code..

                      try:
                          orderparams = {
                              "variety": "STOPLOSS",
                              "tradingsymbol": str(tradingsymbol),
                              "symboltoken": str(symboltoken),
                              "transactiontype":"BUY",
                              "exchange": "NFO",
                              "ordertype": "STOPLOSS_LIMIT",
                              "producttype": "CARRYFORWARD",
                              "duration": "DAY",
                              "price":pricelimit,
                              "triggerprice":triggerprice,
                              "squareoff": "0",
                              "stoploss": "0",
                              "quantity": "50"
                              }
                          orderId=obj.placeOrder(orderparams)
                          return orderId
                      except Exception as e:
                          print(orderparams)   # it's helpful to understand which values you've passed..
                          print("Order placement failed: {}".format(e.message))
                      
                      H N 2 Replies Last reply Reply Quote 0
                      • N
                        neeluru @laxm last edited by

                        @laxm

                        ROBO order is working fine for me.

                        try:
                        orderparams = {
                        "variety": "ROBO",
                        "tradingsymbol": str(tradingsymbol),
                        "symboltoken": str(symboltoken),
                        "transactiontype": str(transactiontype),
                        "exchange": str(symbolexchange),
                        "ordertype": "LIMIT",
                        "producttype": "BO",
                        "duration": "DAY",
                        "price":float(pricelimit),
                        #"triggerprice":100,
                        "squareoff": 12,
                        "stoploss": 12,
                        "quantity": str(quantity)
                        }
                        orderId=client_smartApi.placeOrder(orderparams)
                        return orderId
                        except Exception as e:
                        print("Order placement failed: {}".format(e.message))

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

                          @prasan
                          change quantity ..

                          1 Reply Last reply Reply Quote 0
                          • M
                            mkd last edited by

                            'NoneType' object is not subscriptable

                            1 Reply Last reply Reply Quote 0
                            • M
                              mkd @neeluru last edited by

                              @neeluru change password to mpin

                              1 Reply Last reply Reply Quote 0
                              • H
                                hssandeep @neeluru last edited by

                                @neeluru
                                I tried the above piece of code and it works perfectly with a valid "orderId" but the challenge is on the Angle Broking UI under "Open Orders" this is not reflected.
                                But if you get into "VIEW ORDER HISTORY" page it shows the following error:

                                Reason: 16408 : Trigger price entered has invalid characters

                                Below are the details and have attached the screenshotSTOPLOSS order error on AngelOne UI01012023.png

                                Details
                                Order Placed on 05-Jan-2023 at 14:04:31

                                Product Type
                                Carry Forward - STOPLOSS
                                Action
                                Sell
                                Order Type
                                Stop Loss Limit
                                Validity
                                Day
                                Segment Type
                                F&O
                                Broker Order No.
                                230105001112007
                                Reason: 16408 : Trigger price entered has invalid characters

                                H 1 Reply Last reply Reply Quote 0
                                • N
                                  N210013 last edited by

                                  i am getting error while order placement. my order parameter is as follows:

                                  {'variety': 'NORMAL', 'tradingsymbol': 'IDEA-EQ', 'symboltoken': '14366', 'transactiontype': 'SELL', 'exchange': 'NSE', 'ordertype': 'MARKET', 'producttype': 'DELIVERY', 'duration': 'DAY', 'price': 0.0, 'squareoff': 0.0, 'stoploss': 0.0, 'triggerprice': 0.0, 'trailingstoploss': 0.0, 'quantity': 1}

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

                                    HI @N210013

                                    We have noticed that you are experiencing issues with our SDK due to poor error handling. The error message you are seeing, "TypeError: 'NoneType' object is not subscriptable", is a result of the SDK not handling exceptions properly. This is causing the orderResponse variable to be None, which is leading to the error you are seeing.

                                    The correct error message from the RestAPI is "TPIN is not validated" with error code "AB4013". This error is likely being caused because you are trying to sell delivery holding without TPIN authorization. To read more about the same, please read this post on forums. (https://smartapi.angelbroking.com/topic/2376/only-pre-authoirsed-delivery-sell-orders-will-be-executed-through-smartapi-for-non-poa-clients)

                                    Please note that our SDKs are open source, so you are welcome to make contributions to improve the error handling and other aspects of the code. Additionally, if you encounter any errors in the future, you can make a call to the RestAPI directly to get the correct error message and information on how to resolve the issue.

                                    We apologize for any inconvenience this may have caused and thank you for your understanding.

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

                                      Hello @admin

                                      I'm receiving this error very frequently, sometimes it goes good. For example, yesterday it failed to place the order and today it was able to place the order successfully (no changes made).
                                      I'm following up on this error from many days through multiple threads. But I never got a solution. Can you please respond or make changes as to show the proper reason for the error.

                                      Hope I'll get some resolution this time...Thanks in advance.

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

                                        Hello @admin

                                        Please reply

                                        1 Reply Last reply Reply Quote 0
                                        • H
                                          hssandeep @hssandeep last edited by

                                          Can someone respond to this query? I am stuck here and unable to proceed
                                          Thanks a lot
                                          Sandeep

                                          1 Reply Last reply Reply Quote 0
                                          • N
                                            namit @admin last edited by

                                            Hello @admin
                                            so here is some more info which i get while placing the order.
                                            Basically this error is only coming while i'm trying to place order for options. For equity no error like this is coming.
                                            Also i m getting the following details while placing order which seems to be in your api code..

                                            File "C:\Python311\Lib\site-packages\smartapi\smartConnect.py", line 290, in placeOrder
                                            orderResponse= self._postRequest("api.order.place", params)['data']['orderid']
                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
                                            TypeError: 'NoneType' object is not subscriptable

                                            So you may like to look at line no. 290 in your samrtConnect.py file for more info why this error is getting generated. Looking forward for your reply.
                                            Thanks

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