Closed algowhizz closed 3 years ago
`# hope you know what comes before this client=ks_api.KSTradeApi(access_token,user_id,consumer_key,ip,app_id) login=shubh.login ('password') session=shubh.session_2fa ('acces_code') print(client.session_token)
print(session['sessionToken']) `
Hi, Thanks for the help. However, I knew how to grab the session token but my question was how to pass it to the client without invoking login() and session2fa() everytime when my lambda function runs.
I have implemented something similar to zerodha's kite.set_accesstoken()
and it seems to do the trick.You can check the changelog here if interested :
https://github.com/algowhizz/ks-orderapi-python/commit/4cb939f41c3e2003daa69d72aaffab64c86fd0bd
As we know the access-code(OTP) is valid for 1 day, do you have any idea what is the validity period of Session Token? Thanks.
@algowhizz the session token is valid until a new login is not done if we login second time the session token will be changed
@kalilinux-png , thanks. I am live testing the api today and it is working with session token passed as string. I am getting 2-seconds average executing time while initiating the client using session_token, fetching instrument tokens and LTPs for two option strikes and placing a 2 legged-order.
@algowhizz Glad to hear that api is live I would love to know what are your ideas regarding the trading using this api I am trying to scalp trade using this api or if you like we all user's of kotak can make a groups so that we can share our ideas and could help other
Hi, I have implemented a webhook delivery mechanism where TradingView generates and passes alerts to my AWS lambda function from where the orders are placed in my brokerage account. I am not so sure about scalping because websockets is not currently active on kotakapi, plus I am a trend follower working on a timeframe larger than 15 mins.
i am trying to do scalptrading using ask_price , bid_price, ask_price_quantity , bid_price_quantity and the last traded price to get the live price i used the following code while True: client.quote(instrument_code,'LTP')
i LIKED YOUR IDEA DO HAVE HAVE ANY TIP FOR FASTER ORDER EXECUTION LIKE ITS HARD TO GET FAST ORDER EXECUTION IN NSE
As per this demo https://www.youtube.com/watch?v=_w-p17Oq6lE , the session token needs to be generated only once a day. and gets stored in-memory and can be called by the client at backend without storing it in a json/database or manually fetching it when required. I have a serverless implementation (AWS lambda), where variables like session token needs to be passed from a file or database during the actual api call. I cannot use in-memory variables because the lambda function gets reset to intial state after every API call.
The way zerodha does it is by using the function
kite.set_accesstoken()
.How do I perform a similar operation with kotak API?
Thanks