Code for placing the order using request module


  • Hi All,

    Can someone share the code for placing the order using request module as i'm getting below error "print exception Expecting value: line 1 column 1 (char 0)". Find my code below.

    try:
    orderparams = {
    "variety": "NORMAL",
    "tradingsymbol":"SBIN-EQ",
    "symboltoken": "3045",
    "transactiontype": "BUY",
    "exchange": "NSE",
    "ordertype": "LIMIT",
    "producttype": "INTRADAY",
    "duration": "DAY",
    "price": "10",
    "squareoff": "0",
    "stoploss": "10",
    "quantity": 1
    }

        # #print(ConnObj.placeOrder(orderparams))
        # orderId=ConnObj.placeOrder(orderparams)
        # print("The order id is: {}".format(orderId))
    
        HEADERS = {
            'Authorization': tokenAgle,
            'Content-Type': 'application/json',
            'Accept': 'application/json',
            'X-UserType': 'USER',
            'X-SourceID': 'WEB',
            'X-ClientLocalIP': '127.0.0.1',
            'X-ClientPublicIP': '106.193.147.98',
            'X-MACAddress': '00-15-5D-7D-9C-C3',
            'X-PrivateKey': ANGL_API_KEY
        }
    
        r = requests.post(ORDERS_URL, data=orderparams, headers=HEADERS)
        #print("The order id is: {}".format(orderId))
        print(r)
        response = json.loads(r.content)
        print(response)
    
    except Exception as e:
        print("print exception ", e)

  • @techtrader86 said in Code for placing the order using request module:

    Hi All,

    Can someone share the code for placing the order using request module as i'm getting below error "print exception Expecting value: line 1 column 1 (char 0)". Find my code below.

    try:
    orderparams = {
    "variety": "NORMAL",
    "tradingsymbol":"SBIN-EQ",
    "symboltoken": "3045",
    "transactiontype": "BUY",
    "exchange": "NSE",
    "ordertype": "LIMIT",
    "producttype": "INTRADAY",
    "duration": "DAY",
    "price": "10",
    "squareoff": "0",
    "stoploss": "10",
    "quantity": 1
    }
    # #print(ConnObj.placeOrder(orderparams))
    # orderId=ConnObj.placeOrder(orderparams)
    # print("The order id is: {}".format(orderId))
    HEADERS = {
    'Authorization': tokenAgle,
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'X-UserType': 'USER',
    'X-SourceID': 'WEB',
    'X-ClientLocalIP': '127.0.0.1',
    'X-ClientPublicIP': '106.193.147.98',
    'X-MACAddress': '00-15-5D-7D-9C-C3',
    'X-PrivateKey': ANGL_API_KEY
    }
    r = requests.post(ORDERS_URL, data=orderparams, headers=HEADERS)
    #print("The order id is: {}".format(orderId))
    print(r)
    response = json.loads(r.content)
    print(response)
    except Exception as e:
    print("print exception ", e)