I am Using kite web scraping for get option data But there some issue
isssue :
- when i use while loop for requests.get that time my data not update every time. send same json every time Please check below code
def get_stock_historical_data(token, start_date, end_date, auth_token, timeframe='5minute'):
userid = 'NY4565'
timeframe= timeframe
ciqrandom = '161746886774'
headers = {'Referer' : 'https://kite.zerodha.com/chart/web/', 'Authorization': auth_token}
columns = ['Date','Open','High','Low','Close','V','OI']
final_df = pd.DataFrame(columns=columns)
url = f'https://kite.zerodha.com/oms/instruments/historical/{token}/{timeframe}?user_id={userid}&oi=1&from={start_date}&to={end_date}'
resJson = requests.get(url, headers=headers).json()
candelinfo = resJson['data']['candles']
df= pd.DataFrame(candelinfo, columns=columns)
final_df = final_df.append(df)
final_df = final_df.set_index('Date')
return final_df
while True:
t.sleep(1)
if datetime.now().minute % 1 == 0 and datetime.now().second == 10:
option_price = get_stock_historical_data(stock_token, start_date, end_date, auth_token, interval)
but i run the on streamlit_autorefresh then every time data update...