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