It looks like you're new here. If you want to get involved, click one of these buttons!
while((retry_count < 3 )and(ltp == 0)):
try:
ltp = kite.ltp(symbol)[symbol]['last_price']
except Exception:
log("get ltp exception" + str(Exception.message))
if(ltp == 0):
retry_count = retry_count + 1
time.sleep(1)
return ltp
While i try the above LTP function, the websocket is not running. I would ideally like to run the websocket in the background and this function once in a while in the foreground. I expect the kite.ltp function to work everytime or not work at all.
We ran WebSocket and ltp quote call, in parallel for more than 15 minutes, didn't faced any issue.Are you generating multiple access_token individually for websocket and ltp quote call ?
"will my websocket running in the background stop because of the access_token change"
if you change the access token then .......many a times websocket will stop ...(and sometimes not also).
nope using the same access_token... access_token is getting generated, a thread for a websocket is started and every time a new script needs to be added to the websocket subscription, the script LTP and INSTRUMENT ID are first retrieved using the ltp function.
the ltp function like i mentioned seems to be working sometimes when tried multiple times.
Also it did not work for some specific scripts (APOLLOTYRE) during that test day. Will run the tests again on monday and update.
In the meanwhile what if the script requested has not been traded that day, what will be returned? at the backend how does the ltp function fetch the price? could it be that its picking the ltp from the last tick and that there was no tick generated for that script recently?