Navigation

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

    Code for placing the order using request module

    Python SDK
    1
    2
    32
    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.
    • T
      techtrader86 last edited by

      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)
      
      T 1 Reply Last reply Reply Quote 0
      • T
        techtrader86 @techtrader86 last edited by

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

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