It looks like you're new here. If you want to get involved, click one of these buttons!
from kiteconnect import KiteConnect
api_key=open('api_key.txt','r').read()
api_secret=open('api_secret.txt','r').read()
kite=KiteConnect(api_key=api_key)
kite.set_access_token(open('access_token.txt','r').read())
import datetime
import os
import time
os.environ["TZ"] = "Asia/Kolkata"
time.tzset()
import logging
from kiteconnect import KiteTicker
access_token=(open('access_token.txt','r').read())
logging.basicConfig(level=logging.DEBUG)
kws = KiteTicker("my api key",access_token)
from time import sleep
import time
import xlrd
workbook = xlrd.open_workbook('LP.xls')
worksheet = workbook.sheet_by_index(1)
H2=round(worksheet.cell(10, 14).value)
M2=round(worksheet.cell(10, 15).value)
INTER=round(worksheet.cell(10, 16).value)
INSTR=round(worksheet.cell(10, 9).value)
start_time = datetime.time(H2,M2,0,0)
first_tick_flag = True
def on_ticks(ws, ticks):
global first_tick_flag,start_time
if first_tick_flag:
first_tick_flag = False
start_time = time.time()
end_time = time.time()
if int(end_time - start_time) >=INTER:
start_time = end_time
for tick in ticks:
YB=tick['last_price']
rt1=datetime.datetime.now()
with open('10.txt', 'a') as file:
file.write(str(YB)+"\n")
file.write(str(rt1)+"\n")
def on_connect(ws,response):
ws.subscribe([INSTR])
ws.set_mode(ws.MODE_LTP, [INSTR])
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()
}
Can you paste here complete error traceback? Make sure there is no issue regarding variable assignment in on_ticks method.
Thank you for the response.
Could you please provide code without ws.stop() ? because when I remove the same, python is showing error.
Just last four five lines please.
Thanks in advance.
Please refrain from posting similar query at multiple threads. Follow this thread, for your query and can ask all further queries on the same.