Navigation

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

    Placing order using tokens

    Python SDK
    2
    7
    103
    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

      Dear admin,

      Once we generate a session, how do we place order using just tokens?

      Right now I am doing this:

      client_smartApi = SmartConnect(api_key = client_api_key)
      login = client_smartApi.generateSession("Client_id","Client_password")
      orderId=client_smartApi.placeOrder(orderparams)
      print("OrderId :"+str(orderId))
      
      #obtain the required tokens
      access_token = client_smartApi.access_token
      refreshToken = login['data']['refreshToken']
      jwtToken = login['data']['jwtToken']
      

      The order is successfully placed here.
      As you can see, while placing the order I generateSession for the client using the client ID and the client password.

      However, how do we generate a session initially and then use the tokens to place the orders at a later point in time?

      I tried doing this -

      client_smartApi = SmartConnect(api_key = clien_api_key)
      client_smartApi.setAccessToken(access_token )
      client_smartApi.setRefreshToken(refreshToken )
      orderId=client_smartApi.placeOrder(orderparams)
      

      This throws an error as follows:

      ..........\lib\site-packages\smartapi\smartConnect.py in placeOrder(self, orderparams)
          288                 del(params[k])
          289 
      --> 290         orderResponse= self._postRequest("api.order.place", params)['data']['orderid']
          291 
          292         return orderResponse
      
      TypeError: string indices must be integers
      

      Could you please guide me with this?

      Thank you

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

        @Bharath-Raj-M

        Dear @admin, it's been a while since I posted this, could you review and help us out ?

        Regards,
        Bharath

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

          HI @Bharath-Raj-M I you can use the pubhlisher API to do this.

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

            @admin
            I could not find any documentation regarding this.

            Could you please give a step by step instruction on how it is supposed to be done?

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

              HI @Bharath-Raj-M Post your client id here.

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

                @admin
                My personal client ID is B133022

                1 Reply Last reply Reply Quote 0
                • Q
                  quantplay last edited by

                  Any updates on this?

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