It looks like you're new here. If you want to get involved, click one of these buttons!
from kiteconnect import KiteTicker
kws = KiteTicker("my api key","my access token")
def on_ticks(ws, ticks):
M1=datetime.time(13,42,30,100000)
M2=datetime.time(13,43,0,100000)
today=datetime.date.today()
a=datetime.datetime.combine(today,M1)
b=datetime.datetime.combine(today,M2)
rt1=datetime.datetime.now()
if(rt1<b)and (rt1>a):
for tick in ticks:
RL1=tick['last_price']
print('RL1=',RL1)
time.sleep(60)
RL2=tick['last_price']
print('RL2=',RL2)
time.sleep(60)
RL3=tick['last_price']
print('RL3=',RL3)
ws.close()
def on_connect(ws,response):
ws.subscribe([738561])
ws.set_mode(ws.MODE_LTP, [738561])
def on_close(ws,code,reason):
ws.stop()
kws.on_ticks=on_ticks
kws.on_connect=on_connect
kws.on_close=on_close
kws.connect()close()
def on_connect(ws,response):
ws.subscribe([738561])
ws.set_mode(ws.MODE_LTP, [738561])
def on_close(ws,code,reason):
ws.stop()
kws.on_ticks=on_ticks
kws.on_connect=on_connect
kws.on_close=on_close
kws.connect()
Using time.sleep inside on_ticks callback and expecting new tick is wrong.
Also once you issue ws.close inside on_ticks callback it will stop the event loop which you cant restart in the same process.