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


  • @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))


  • @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))

  • @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.


  • @neeluru

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


  • @admin

    Thanks admin.. It's working well now.


  • 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.


  • @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


  • @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
    }


  • @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
    }


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

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

    wrong exchange