Error while placing order


  • Getting Below error while placing order. We have used the exact same values from documentation including sending order for SBIN-EQ. Request to kindly check if the placeOrder functionality is working? Or if we have to send any additional parameter kindly let us know.

    /rest/secure/angelbroking/order/v1/placeOrder
    https://apiconnect.angelbroking.com/rest/secure/angelbroking/order/v1/placeOrder
    The Response Content b''
    Traceback (most recent call last):
    File "C:\Anaconda\lib\site-packages\smartapi\smartConnect.py", line 195, in request
    data = json.loads(r.content.decode("utf8"))
    File "C:\Anaconda\lib\json_init
    .py", line 357, in loads
    return _default_decoder.decode(s)
    File "C:\Anaconda\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File "C:\Anaconda\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 "test.pyw", line 447, in placeOrderAngel
    orderId = obj.placeOrder(orderparams)
    File "C:\Anaconda\lib\site-packages\smartapi\smartConnect.py", line 295, in placeOrder
    orderResponse= self._postRequest("api.order.place", params)['data']['orderid']
    File "C:\Anaconda\lib\site-packages\smartapi\smartConnect.py", line 227, in _postRequest
    return self._request(route, "POST", params)
    File "C:\Anaconda\lib\site-packages\smartapi\smartConnect.py", line 198, 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 "test.pyw", line 495, in main
    placeOrderAngel("SBIN-EQ", "3045", "BUY", 25)
    File "test.pyw", line 450, in placeOrderAngel
    print("Order placement failed: {}".format(e.message))
    AttributeError: 'DataException' object has no attribute 'message'


  • @A111706 did you find solution for 400 Bad request error? Am also facing the same issue. I get this error only in Postman but works good in Python.


  • I am trying to place order from postman. Always I am getting 400 bad request error. I am able to get result from OrderBook API. So access token is correct.

    Below is the request:
    47227944-d1c1-4182-8cd5-2d3a47ba0ca2-image.png

    Headers:

    104faa83-2b5f-4184-a650-b4e46c1cac10-image.png


  • getting error while placing order' string indices must be integers.
    using sample.py


  • @harish said in Error while placing order:

    BANKNIFTY20D1030000CE

    There seems to be an error in trading symbol. It should be "BANKNIFTY10DEC2030000CE".

    Please refer to our API documentation to retrieve the list of instruments.


  • @harish I'm able to place the weekly options order for USDINR and it was successfully placed. So I guess Angel has blocked the weekly options for BANKNIFTY as volatility is high currently.


  • @harish Getting this checked.


  • @bhaveshjain Sir Kindly check the above issue in weekly option order placing. Orders are getting blocked with error "RMS:Field Not Found 63002". We are able process the orders for monthly futures and options but Index weekly options we are facing issue.


  • @rjbanna Sir monthly option we are able to place order as you mentioned. But weekly i guess RMS has blocked placing orders or it is still not enabled in the API. Order gets rejected with message "Order Rejected
    RMS:Field Not Found 63002"

    try:
        orderparams = {
            "variety": "NORMAL",
            "tradingsymbol": "BANKNIFTY20D1030000CE",
            "symboltoken": "40919",
            "transactiontype": "BUY",
            "exchange": "NFO",
            "ordertype": "LIMIT",
            "producttype": "INTRADAY",
            "duration": "DAY",
            "price": "250",
            "squareoff": "0",
            "stoploss": "0",
            "quantity": "25"
            }
    

  • @harish I'm able to place the order. I don't see any issues. Make sure you are passing the valid symboltoken and tradingsymbol. I tried with "BANKNIFTY31DEC2028200CE" and "36482" and it was successfully placed.


  • @rjbanna Sir have you tried placing FNO order, getting this error RMS:Field Not Found 63002

    bc27d921-9396-40d5-9675-f9d3a19d8924-image.png


  • @dorje Haven't tried steaming data yet will try and let you know if it works.


  • @rjbanna thanks boss, it worked was using refreshToken which was creating issue after generateSession function.

    Working now👍


  • @harish hi harish are you able to stream tick data , if yes could you please let us know how you did that.


  • @harish I tried to place the order and it was successful from my side. Below is the code that I used.

            obj = SmartConnect(api_key="API_KEY")
    	data = obj.generateSession("CLIENT_ID","PWD")
    
    	try:
    		orderparams = {
    			"variety": "NORMAL",
    			"tradingsymbol": "SBIN-EQ",
    			"symboltoken": "3045",
    			"transactiontype": "BUY",
    			"exchange": "NSE",
    			"ordertype": "LIMIT",
    			"producttype": "INTRADAY",
    			"duration": "DAY",
    			"price": "195",
    			"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))
    

  • Dear @bhaveshjain

    Sir kindly check above issue once we are facing this issue while placing order. Tried exact code as given in documentation for SBIN but still getting error.


  • @rjbanna sir yesterday got a mail to reset password from Angel broking after that we were able to login. We faced login error till yesterday which you have mentioned. It is fixed now.

    We are facing issue in sending orders. tried the same code as in documentation still getting error.


  • @harish I think your credentials are not correct and if they are correct kindly confirm if your account has been migrated to the new Angel Broking server or not. Because I was also getting the same issue and once my account got migrated, the issue was resolved. There are many people with this same issue.


  • @harish File "C:\Anaconda\lib\site-packages\smartapi\smartConnect.py", line 235, in generateSession
    loginResultObject=self._postRequest("api.login",params)
    File "C:\Anaconda\lib\site-packages\smartapi\smartConnect.py", line 227, in _postRequest
    return self._request(route, "POST", params)
    File "C:\Anaconda\lib\site-packages\smartapi\smartConnect.py", line 198, 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''