Navigation

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

    string indices must be integers

    Python SDK
    2
    4
    84
    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
      C1234 last edited by

      Re: Error while placing order

      Hey whenever I place my orders, the orders usually get executed, however sometimes, I get the error:
      "string indices must be integers"

      Here is a gist of my code:

      client_smartApi=SmartConnect(api_key='api_key')
      login = client_smartApi.generateSession('Client_id','password')
      try:
      orderparams = {
      "variety": "NORMAL",
      "tradingsymbol": tradingsymbol,
      "symboltoken": symbol_token,
      "transactiontype": transactiontype,
      "exchange": symbolexchange,
      "ordertype": "MARKET",
      "producttype": "CARRYFORWARD",
      "duration": "DAY",
      "quantity": quantity
      }
      orderId=client_smartApi.placeOrder(orderparams)
      except Exception as e:
      print(e)

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

        HI @Bharath-Raj-M Please go through the below req, You have not passed few parameter as string.
        {
        "variety":"NORMAL",
        "tradingsymbol":"SBIN-EQ",
        "symboltoken":"3045",
        "transactiontype":"BUY",
        "exchange":"NSE",
        "ordertype":"MARKET",
        "producttype":"INTRADAY",
        "duration":"DAY",
        "price":"194.50",
        "squareoff":"0",
        "stoploss":"0",
        "quantity":"1"
        }

        1 Reply Last reply Reply Quote 0
        • C
          cthomas last edited by

          @Bharath-Raj-M Did you get this problem solved? I am facing the same issue and it is very intermittent.
          If this is solved. can you please let me know how?

          1 Reply Last reply Reply Quote 0
          • V
            virajkadam last edited by

            Hello Guys,

            the solution is to reset token, as below.

            try:
            data = self.obj.generateSession(client_id,Password)
            return data['data']['refreshToken']
            except Exception as e:
            print ("Login failed: {}".format(e))

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